Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
h2. SJMS Component

*Available as of Camel 2.11*

{note}
This component is under active development.
{note}

The SJMS Component is a JMS client for Camel based purely on the JMS API.  It will be released as part of Camel 2.11 with the following functionality:

* Queue and Topic Support (Durable & Non-Durable)
* InOnly & InOut Support
* Plugable Connection Resource Management
* Session, Consumer, & Producer Pooling & Caching Management
* Asynchronous Producer and Consumer Processing
* Internal JMS Transaction Support

{info:title=Why the S in SJMS}
S stands for Simple and Standard and Springless.  Also camel-jms was already taken. :)
{info}

Maven users will need to add the following dependency to their {{pom.xml}} for this component:
{code:xml}
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-sjms</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
{code}

h3. URI format

{code}
sjms:[queue:|topic:]destinationName[?options]
{code}

Where {{destinationName}} is a JMS queue or topic name. By default, the {{destinationName}} is interpreted as a queue name. For example, to connect to the queue, {{FOO.BAR}} use:

{code}
sjms:FOO.BAR
{code}

You can include the optional {{queue:}} prefix, if you prefer:

{code}
sjms:queue:FOO.BAR
{code}

To connect to a topic, you _must_ include the {{topic:}} prefix. For example, to connect to the topic, {{Stocks.Prices}}, use:

{code}
sjms:topic:Stocks.Prices
{code}

You append query options to the URI using the following format, {{?option=value&option=value&...}}

h3. SjmsComponent Options and Configurations

Below is an example of how to configure the SjmsComponent with its required ConnectionFactory provider.  It will create a single connection by default and store it using the components internal pooling APIs to ensure that it is able to service Session creation requests in a thread safe manner.

{code}
SjmsComponent component = new SjmsComponent();
component.setConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616"));
getContext().addComponent("sjms", component);
{code}

For a SjmsComponent that is required to support a durable subscription, you can override the default ConnectionFactoryResource instance and set the *clientId* property.

{code}
ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
connectionResource.setConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616"));
connectionResource.setClientId("myclient-id");

SjmsComponent component = new SjmsComponent();
component.setConnectionResource(connectionResource);
component.setMaxConnections(1);
{code}

h3. Producers

The SjmsProducer Endpoint supports the following properties:

{div:class=confluenceTableSmall}
|| Option || Default Value || Description ||
| {{acknowledgementMode}} | {{AUTO_ACKNOWLEDGE}}  | The JMS acknowledgement name, which is one of: {{TRANSACTED}}, {{CLIENT_ACKNOWLEDGE}}, {{AUTO_ACKNOWLEDGE}}, {{DUPS_OK_ACKNOWLEDGE}} |
| {{consumerCount}} | {{1}}  | Defines the number of MessageListener instances that will be used with the InOut endpoint. |
| {{exchangePattern}} | {{InOnly}}  | Sets the Producers message exchange pattern. |
| {{namedReplyTo}} | {{null}}  | Specifies a named reply to destination for InOut endpoint. |
| {{producerCount}} | {{1}}  | Defines the number of MessageProducer instances. |
| {{responseTimeOut}} | {{5000}}  | Specifies the amount of time an InOutProducer will wait for its response. |
| {{synchronous}} | {{true}}  | Sets whether the Endpoint will use synchronous or asynchronous processing. |
| {{ttl}} | {{-1}}  | Disabled by default.  Sets the Message time to live header. |
{div}

h4. InOnly Producer - (Default)

The InOnly Producer is the default behavior of the SJMS Producer Endpoint.

{code}
from("direct:start")
    .to("sjms:queue:bar");
{code}

h4. InOut Producer

To enable InOut behavior with the 

{code}
from("direct:start")
    .to("sjms:queue:bar?exchangePattern=InOut");
{code}

h4. SJMS Consumer

{code}
{code}

h4. Transactions {anchor:transactionCacheLevels}

There is currently no support the Camel Transaction Processor nor does it support the Camel Transaction API.