...
The WSDL extensions for defining a JMS endpoint are defined in the namespace http://cxf.apache.org/transports/jms
. In order to use the JMS extensions you will need to add the line namespace definition shown below to the definitions element of your contract.
Code Block | ||
---|---|---|
| ||
xmlns:jms="http://cxf.apache.org/transports/jms" |
Configuration Namespaces
The CXF JMS endpoint configuration properties are specified under the http://cxf.apache.org/transports/jmscontains
namespace. In order to use the JMS configuration properties you will need to add the lines shown below to the beans
element of your configuration.
...
JMS endpoints need to know certain basic information about how to establish a connection to the proper destination. This information can be provided in one of two places:
...
WSDL or XML configuration. The following configuration elements which are described can be used in both the client side Conduits and the server side Destinations.
Using WSDL
The JMS destination information is provided using the jms:address
element and its child, the jms:JMSNamingProperties
element. The jms:address
element's attributes specify the information needed to identify the JMS broker and the destination. The jms:JMSNamingProperties
element specifies the Java properties used to connect to the JNDI service.
...
In addition to using the WSDL file to specify the connection information for a JMS endpoint, you can also supply it in the endpoint's XML configuration file. The information in the configuration file will override the information in the endpoint's WSDL file.
Configuration beans
You use the org.apache.cxf.transport.jms.base.JMSTransportBaseConfigBean
bean class to specify the address for a JMS endpoint. The value if the configuration bean's id
attribute determines if you are configuring a consumer endpoint or a service endpoint. The id
values will take one of the following forms:
- {
WSDLNamespace}WSDLPortName.jms-conduit-base
specifies that a consumer endpoint is being configured - {
WSDLNamespace}WSDLPortName.jms-destination-base
specifies that a service endpoint is being configured
The addressPolicy property
JMS connection information is specified using the addressPolicy
property. The addressPolicy
property has a single value: jms:address
. It is identical to the jms:address
element used in the WSDL file.
Like the jms:address
element in the WSDL file, the jms:address
configuration element also has a jms:JMSNamingProperties
child element that is used to specify additional information used to connect to a JNDI provider.
The addressPolicy
property can be specified in either the client base configuration bean or the service base configuration bean.
The following example shows a CXF configuration entry for configuring the addressing information for a JMS consumer endpoint.
The addressPolicy property
JMS connection information is specified using the addressPolicy
property. The addressPolicy
property has a single value: jms:address
. It is identical to the jms:address
element used in the WSDL file. Like the jms:address
element in the WSDL file, the jms:address
configuration element also has a jms:JMSNamingProperties
child element that is used to specify additional information used to connect to a JNDI provider. The following example shows a CXF configuration entry for configuring the addressing information for a JMS consumer endpoint.
Code Block | ||
---|---|---|
| ||
<beans xmlns="http://www.springframework.org/schema/beans | ||
Code Block | ||
| ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ctxsi="http://cxfwww.apachew3.org/configuration2001/typesXMLSchema-instance" xmlns:jmsct="http://cxf.apache.org/transportsconfiguration/jmstypes" xmlns:jms-conf="http://cxf.apache.org/transports/jms/jms-conf" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean<jms:conduit id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit-base" class="org.apache.cxf.transport.jms.base.JMSTransportBaseConfigBean"> <property name="addressPolicy"-conduit"> <value> <jms:address destinationStyle="queue" jndiConnectionFactoryName="myConnectionFactory" jndiDestinationName="myDestination" jndiReplyDestinationName="myReplyDestination" connectionUserName="testUser" connectionPassword="testPassword"> <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.cxf.transport.jms.MyInitialContextFactory"/> <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61616"/> </jms:address> </value> </property> </bean>jms:conduit> </beans> |
The jms:address
may also be used inside a jms:destination
as well (see below).
Consumer Endpoint Configuration
JMS consumer endpoints specify the type of messages they use. JMS consumer endpoint can use either a JMS ObjectMessage
or a JMS TextMessage
. When using an ObjectMessage
the consumer endpoint uses a byte[]
as the method for storing data into and retrieving data from the JMS message body. When messages are sent, the message data, including any formating information, is packaged into a byte[]
and placed into the JMS message body before it is placed on the wire. When messages are received, the consumer endpoint will attempt to unmarshall the data stored in the JMS body as if it were packed in a byte[]
.
When using a TextMessage
, the consumer endpoint uses a string as the method for storing and retrieving data from the JMS message body. When messages are sent, the message information, including any format-specific information, is converted into a string and placed into the JMS message body. When messages are received the consumer endpoint will attempt to unmashall the data stored in the JMS message body as if it were packed into a string.
When native JMS applications interact with CXF consumers, the JMS application is responsible for interpreting the message and the formatting information. For example, if the CXF contract specifies that the binding used for a JMS endpoint is SOAP, and the messages are packaged as TextMessage
, the receiving JMS application will get a text message containing all of the SOAP envelope information.
Consumer endpoint can be configured in one of two ways:
- Configuration
- WSDL
Using Configuration
Specifying the message type
be configured by both XML configuration and via WSDL.
Using Configuration
Specifying the message type
You can Consumer endpoint configuration is specified using org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean
as the class for the configuration bean. Using this configuration bean, you specify the message type supported by the consumer endpoint using the client property. It has a single value, jms:client
, element that has a single attribute:
...
Code Block | ||
---|---|---|
| ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/beans" xmlns:ctxsi="http://cxfwww.apachew3.org/configuration2001/typesXMLSchema-instance" xmlns:jmsct="http://cxf.apache.org/transportsconfiguration/jmstypes" xmlns:jms-conf="http://cxf.apache.org/transports/jms/jms-conf" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> ... <bean<jms:conduit id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit" class="org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean"> <property name="client"conduit"> <value> <jms:client messageType="binary"/> </value> </property> ... </bean> ... </beans> |
Specifying address information
jms:conduit>
...
</beans>
|
The id on the jms:conduit
is The addressing information for a JMS consumer endpoint is set using a configuration bean with a class of org.apache.cxf.transort.jms.base.JMSTransportBaseConfigBean
and an id in the form of {WSDLNamespace}WSDLPortName.jms-conduit-base
. This provides CXF with the information so that it can associate the configuration with your service's endpoint.
Using WSDL
The type of messages accepted by a JMS consumer endpoint is configured using the optional jms:client
element. The jms:client
element is a child of the WSDL port element and has one attribute:
...
Service endpoints can be configure in one of two ways:
- Configuration
- WSDL
Using Configuration
Specifying configuration data
Using Configuration
Specifying configuration data
Using the jms:destination
element you can configure your service's endpoint to use JMS. You can Service endpoints are configured using the org.apache.cxf.transport.jms.destination.JMSDestinationConfigBean} class for the configuration bean. Using this configuration bean class, you can specify the service endpoint's behaviors using the {{server
property. It has a single element, jms:server
, that has a the following attributes:
...
Code Block | ||
---|---|---|
| ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="http://cxfwww.apachew3.org/configuration2001/typesXMLSchema-instance" xmlns:jmsct="http://cxf.apache.org/transportsconfiguration/jmstypes" xmlns:jms-conf="http://cxf.apache.org/transports/jms/jms-conf" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> ... <bean<jms:destination id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination" class="org.apache.cxf.transport.jms.destination.JMSDestinationConfigBean"> <property name="server"> <value>> <jms:server messageSelector="cxf_message_selector" useMessageIDAsCorrelationID="true" transactional="true" durableSubscriberName="cxf_subscriber" /> </value> </property> </bean> ... </beans> |
Adding address information
The addressing information for a JMS service endpoint is set using a configuration bean with a class of org.apache.cxf.transort.jms.base.JMSTransportBaseConfigBean
and an id in the form of {WSDLNamespace}WSDLPortName.jms-destination-base
. jms:address
described above can also be embedded in the jms:destination
:
Code Block | ||
---|---|---|
| ||
<jms:destination id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination">
<jms:address .../>
<jms:server .../>
</bean>
|
Using WSDL
Service endpoint behaviors are configured using the optional jms:server
element. The jms:server
element is a child of the WSDL port
element and has the following attributes:of the WSDL port
element and has the following attributes:
Attribute | Description |
---|---|
| Specifies whether JMS will use the message ID to correlate messages |
Attribute | Description |
| Specifies whether JMS will use the message ID to correlate messages. The default is |
| Specifies the name used to register a durable subscription. |
| Specifies the string value of a message selector to use. For more information on the syntax used to specify message |
| Specifies whether the local JMS broker will create transactions around message processing. The default is |
JMS Runtime Configuration
In addition to configuring the externally visible aspects of your JMS endpoint, you can also configure aspects of its internal runtime behavior. There are three types of runtime configuration:
- Base configuration
- Consumer specific configuration
- Service specific configuration
Base Runtime Configuration
The JMS base configuration allows you to specify the number of JMS sessions an endpoint will keep in a pool. This property is specified using the same configuration bean as the endpoint's address configuration.
Configuration bean
You use the org.apache.cxf.transport.jms.base.JMSTransportBaseConfigBean
bean class to specify the session pool configuration for a JMS endpoint. The value if the configuration bean's id attribute determines if you are configuring a consumer endpoint or a service endpoint. The id values will take one of the following forms:
- {
WSDLNamespace}WSDLPortName.jms-conduit-base
specifies that a consumer endpoint is being configured. - {
WSDLNamespace}WSDLPortName.jms-destination-base
specifies that a service endpoint is being configured.
...
| Specifies the name used to register a durable subscription. |
| Specifies the string value of a message selector to use. For more information on the syntax used to specify message |
| Specifies whether the local JMS broker will create transactions around message processing. The default is |
JMS Runtime Configuration
In addition to configuring the externally visible aspects of your JMS endpoint, you can also configure aspects of its internal runtime behavior. There are three types of runtime configuration:
- Session pool configuration (common to both services and consumers)
- Consumer specific configuration
- Service specific configuration
Session Pool Configuration
You configure an endpoint's JMS session pool using the sessionPoolConfig
property. This property allows you to set a high and low water mark for the number of JMS sessions an endpoint will keep pooled. The endpoint is guaranteed to maintain a pool of sessions equal to the low water mark and to never pool more sessions than specified by the high water mark.
The sessionPoolConfig
sessionPool
property takes a single jms-conf:sessionPoolConfigsessionPool
element. The jms-conf:sessionPoolConfigsessionPool
element's attributes, listed below, specify the high and low water marks for the endpoint's JMS session pool.
...
Code Block | ||
---|---|---|
| ||
<bean<jms:destination id="{http://cxf.apache.org/jms_endpit}HelloWorldJMSPort.jms-destination-base" class="org.apache.cxf.transport.jms.base.JMSTransportBaseConfigBean"> ... <property name="sessionPoolConfig"> <value> <jms-conf:sessionPoolConfigsessionPool lowWaterMark="10" highWaterMark="5000" /> </value> </property> </bean> jms:destination> |
The jms:sessionPool
element can also be used within a jms:conduit
.
Consumer Specific Runtime Configuration
...
- the number of milliseconds the consumer will wait for a response.
- the number of milliseconds a request will exist before the JMS broker can remove it.
Configuration bean
You configure consumer runtime behavior using the org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean
configuration bean class.
Configuration property
You use the clientConfig
property to set JMS consumer runtime behavior. This property has a single element called jms-conf:clientConfig
. This element's attributes, listed in the following table, specify the configuration values for consumer runtime behavior.
...
Code Block | ||
---|---|---|
| ||
<bean id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit" class="org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean<jms:conduit id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit"> ... <property name="clientConfig"> <value> <jms-conf:clientConfigruntimePolicy clientReceiveTimeout="500" messageTimeToLive="500" /> </value> </property> </bean></jms:conduit> |
Service Specific Runtime Configuration
...
- the amount of time a response message can remain unreceived be fore the JMS broker can delete it.
- the client identifier used when creating and accessing durable subscriptions.
Configuration bean
...
- .
...
The serverConfig
property is used to specify the service runtime configuration. It takes a single jms-conf:serverConfig
element. This element's attributes, listed below, specify the configuration values that control the service's runtime behavior.
...
Code Block | ||
---|---|---|
| ||
<bean<jms:destination id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination" class="org.apache.cxf.transport.jms.destination.JMSDestinationConfigBean"> ... <property name="serverConfig"> <value> <jms-conf:serverConfigcxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination"> <jms:runtimePolicy messageTimeToLive="500" durableSubscriptionClientId="jms-test-id" /> </value> </property> </bean></jms:destination> |