Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
13.2. JMS URIs
Overview
Syntax
?
). Multiple options are separated by an ampersand(&
). Example 13.4, “Syntax for JMS URI options” shows the syntax for using multiple options in a JMS URI.
Example 13.4. Syntax for JMS URI options
jms:variant:jmsAddress?option1=value1&option2=value2&...optionN=valueN
JMS properties
Property | Default | Description |
---|---|---|
conduitIdSelectorPrefix | [Optional] A string value that is prefixed to all correlation IDs that the conduit creates. The selector can use it to listen for replies. | |
deliveryMode | PERSISTENT | Specifies whether to use JMS PERSISTENT or NON_PERSISTENT message semantics. In the case of PERSISTENT delivery mode, the JMS broker stores messages in persistent storage before acknowledging them; whereas NON_PERSISTENT messages are kept in memory only. |
durableSubscriptionClientID | [Optional] Specifies the client identifier for the connection. This property is used to associate a connection with a state that the provider maintains on behalf of the client. This enables subsequent subscribers with the same identity to resume the subscription in the state that the preceding subscriber left it. | |
durableSubscriptionName | [Optional] Specifies the name of the subscription. | |
messageType | byte |
Specifies the JMS message type used by CXF. Valid values are:
|
password | [Optional] Specifies the password for creating the connection. Appending this property to the URI is discouraged. | |
priority | 4 | Specifies the JMS message priority, which ranges from 0 (lowest) to 9 (highest). |
receiveTimout | 60000 | Specifies the time, in milliseconds, the client will wait for a reply when request/reply exchanges are used. |
reconnectOnException | true |
[Deprecated in CXF 3.0] Specifies whether the transport should reconnect when exceptions occur.
As of 3.0, the transport will always reconnect when an exception occurs.
|
replyToName |
[Optional] Specifies the reply destination for queue messages. The reply destination appears in the
JMSReplyTo header. Setting this property is recommended for applications that have request-reply semantics because the JMS provider will assign a temporary reply queue if one is not specified.
The value of this property is interpreted according to the variant specified in the JMS URI:
| |
sessionTransacted | false |
Specifies the transaction type. Valid values are:
|
timeToLive | 0 | Specifies the time, in milliseconds, after which the JMS provider will discard the message. A value of 0 indicates an infinite lifetime. |
topicReplyToName |
[Optional] Specifies the reply destination for topic messages. The value of this property is interpreted according to the variant specified in the JMS URI:
| |
useConduitIdSelector | true |
Specifies whether the conduit's UUID will be used as the prefix for all correlation IDs.
As all conduits are assigned a unique UUID, setting this property to
true enables multiple endpoints to share a JMS queue or topic.
|
username | [Optional] Specifies the username to use to create the connection. |
JNDI properties
Property | Description |
---|---|
jndiConnectionFactoryName | Specifies the JNDI name of the JMS connection factory. |
jndiInitialContextFactory | Specifies the fully qualified Java class name of the JNDI provider (which must be of javax.jms.InitialContextFactory type). Equivalent to setting the java.naming.factory.initial Java system property. |
jndiTransactionManagerName | Specifies the name of the JTA transaction manager that will be searched for in Spring, Blueprint, or JNDI. If a transaction manager is found, JTA transactions will be enabled. See the sessionTransacted JMS property. |
jndiURL | Specifies the URL that initializes the JNDI provider. Equivalent to setting the java.naming.provider.url Java system property. |
Additional JNDI properties
java.naming.factory.initial
and java.naming.provider.url
, are standard properties, which are required to initialize any JNDI provider. Sometimes, however, a JNDI provider might support custom properties in addition to the standard ones. In this case, you can set an arbitrary JNDI property by setting a URI option of the form jndi-PropertyName
.
java.naming.factory.control
, in a JMS URI as shown in Example 13.5, “Setting a JNDI property in a JMS URI”.
Example 13.5. Setting a JNDI property in a JMS URI
jms:queue:FOO.BAR?jndi-java.naming.factory.control=com.sun.jndi.ldap.ResponseControlFactory
Example
test.cxf.jmstransport.queue
, use the URI shown in Example 13.6, “JMS URI that configures a JNDI connection”.
Example 13.6. JMS URI that configures a JNDI connection
jms:jndi:dynamicQueues/test.cxf.jmstransport.queue ?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory &jndiConnectionFactoryName=ConnectionFactory &jndiURL=tcp://localhost:61616
Publishing a service
publish()
method cannot be used to publish a SOAP/JMS service. Instead, you must use the Apache CXF's JaxWsServerFactoryBean
class as shown in Example 13.7, “Publishing a SOAP/JMS service”.
Example 13.7. Publishing a SOAP/JMS service
1String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3" + "?jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiConnectionFactoryName=ConnectionFactory" + "&jndiURL=tcp://localhost:61500"; Hello implementor = new HelloImpl(); 2JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setServiceClass(Hello.class); 3svrFactory.setAddress(address); 4svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID); svrFactory.setServiceBean(implementor); svrFactory.create();
Consuming a service
JaxWsProxyFactoryBean
class as shown in Example 13.8, “Consuming a SOAP/JMS service”.
Example 13.8. Consuming a SOAP/JMS service
// Java public void invoke() throws Exception { 1 String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3" + "?jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61500"; 2 JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); 3 factory.setAddress(address); 4 factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID); factory.setServiceClass(Hello.class); Hello client = (Hello)factory.create(); String reply = client.sayHi(" HI"); System.out.println(reply); }