JBI Component
The jbi: component is provided implemented by the ServiceMix Camel module and provides integration with a JBI Normalized Message Router, such as the one provided by Apache ServiceMix.
Info | ||||
---|---|---|---|---|
| ||||
See below for information about how to use |
The following code:Following code
Code Block |
---|
from("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint") |
automatically Automatically exposes a new endpoint to the bus, where the service qname QName is {http://foo.bar.org
}MyService
and the endpoint name is MyEndpoint
(refer to URI format latersee #URI-format).
All that has to be done to use this endpoint is to send messages from some endpoint already declared (for example with jms:endpoint
) to this JBI camel endpoint (the same way as messages are sent to EIP endpoints or any other endpoint) and camel will pick it up the same way as it picks any other messages.
Sending works in the same wayWhen a JBI endpoint appears at the end of a route, for example:
Code Block |
---|
to("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint") |
Is used to send messages to JBI endpoint already deployed to the bus. It could be an endpoint exposed by jms:endpoint
, http:provider
or anything else.
URI format
The messages sent by this producer endpoint are sent to the already deployed JBI endpoint.
Anchor | ||||
---|---|---|---|---|
|
URI format
Code Block |
---|
jbi:service:serviceNamespace[sep]serviceName[?options] jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName[?options] jbi:name:endpointName[?options] |
The separator used will bethat should be used in the endpoint URL is:
- '
/
' if the namespace looks like ' (forward slash), ifserviceNamespace
starts withhttp://
', or' :
' if the namespace looks like ' (colon), ifserviceNamespace
starts withurn:foo:bar
'.
For more details of valid JBI URIs see the ServiceMix URI Guide.
Using the jbi:service:
or jbi:endpoint:
URI forms will set formats sets the service QName on the JBI endpoint to the exact one you givespecified. Otherwise, the default Camel JBI Service QName will be is used, which is:
Code Block |
---|
{http://activemq.apache.org/camel/schema/jbi}endpoint |
You can append query options to the URI in the following format, ?option=value&option=value&...
Examples
Code Block |
---|
jbi:service:http://foo.bar.org/MyService jbi:endpoint:urn:foo:bar:MyService:MyEndpoint jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint jbi:name:cheese |
URI options
Name | Default value | Description |
---|---|---|
| MEP of the Camel Exchange | Allows users to override the MEP set on the Exchange object. Valid values for this option are |
| Value of the | Specifies the JBI operation for the |
| | Default value ( |
| | |
Examples
Code Block |
---|
jbi:service:http://foo.bar.org/MyService?mep=in-out (override the MEP, use InOut JBI MessageExchanges)
jbi:endpoint:urn:foo:bar:MyService:MyEndpoint?mep=in (override the MEP, use InOnly JBI MessageExchanges)
jbi:endpoint:urn:foo:bar:MyService:MyEndpoint?operation={http://www.mycompany.org}AddNumbers
(overide the operation for the JBI Exchange to {http://www.mycompany.org}AddNumbers)
|
Using Stream bodies
If you are using a stream type as the message body, you should be aware that a stream is only capable of being read once. So if you enable DEBUG
logging, the body is usually logged and thus read. To deal with this, Camel has a streamCaching
option that can cache the stream, enabling you to read it multiple times.
Code Block |
---|
from("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint").streamCaching().to("xslt:transform.xsl", "bean:doSomething");
|
The stream caching is default enabled, so it is not necessary to set the streamCaching()
option.
We store big input streams (by default, over 64K) in a temp
file using CachedOutputStream
. When you close the input stream, the temp file will be deleted.
Creating a JBI Service Unit
If you have some Camel routes that you want to deploy inside JBI as a Service Unit, you can use the JBI Service Unit Archetype to create a new Maven project for the Service Unit.
If you have an existing maven Maven project which that you need to convert into a JBI Service Unit, you may want to refer to the consult ServiceMix Maven JBI Plugins for further help. Basically you just need to make sureThe key steps are as follows:
- Create a Spring you have a spring XML file at
src/main/resources/camel-context.xml
which is used to boot up bootstrap your routes inside the JBI Service Unit. - you change Change the pomPOM file's packaging to
jbi-service-unit
.
Your pom.xml
should look something like this to enable the jbi-service-unit
packaging. :
Code Block |
---|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>myGroupId</groupId> <artifactId>myArtifactId</artifactId> <packaging>jbi-service-unit</packaging> <version>1.0-SNAPSHOT</version> <name>A Camel based JBI Service Unit</name> <url>http://www.myorganization.org</url> <properties> <camel-version>1version>x.0x.0<x</camel-version> <servicemix-version>3.2-incubating<3</servicemix-version> </properties> <dependencies> <dependency> <groupId>org.apache.camel<servicemix</groupId> <artifactId>camel<artifactId>servicemix-jbi<camel</artifactId> <version>${camelservicemix-version}</version> </dependency> <dependency> <groupId>org.apache.servicemix</groupId> <artifactId>servicemix-core</artifactId> <version>${servicemix-version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <defaultGoal>install</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <!-- creates the JBI deployment unit --> <plugin> <groupId>org.apache.servicemix.tooling</groupId> <artifactId>jbi-maven-plugin</artifactId> <version>${servicemix-version}</version> <extensions>true</extensions> </plugin> </plugins> </build> </project> |
Include Page | ||||
---|---|---|---|---|
|