JMS TransportPage edited by Daniel KulpChanges (2)
Full ContentUsing the Java Message Service (JMS)CXF provides a transport plug-in that enables endpoints to use Java Message Service (JMS) queues and topics. CXF's JMS transport plug-in uses the Java Naming and Directory Interface (JNDI) to locate and obtain references to the JMS provider that brokers for the JMS destinations. Once CXF has established a connection to a JMS provider, CXF supports the passing of messages packaged as either a JMS ObjectMessage or a JMS TextMessage. Easier configuration using the new JMSConfigFeatureStarting with CXF 2.0.9 and 2.1.3 there is a new easier and more flexible configuration style available. See Using the JMSConfigFeature JMS Transport with SOAP over Java Message Service 1.0-SupportedStarting with the CXF 2.3, we make some improvement on the JMS Transport to support SOAP over JMS specification. See SOAP over JMS 1.0 support for more information. JMS NamespacesWSDL NamespaceThe 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 namespace definition shown below to the definitions element of your contract. JMS Extension Namespace
xmlns:jms="http://cxf.apache.org/transports/jms"
The address elementJMS connection information is specified by adding a jms:address child to the base configuration element. The jms:address element used in the configuration file is identical to the one used in the WSDL file. Its attributes are listed in the address element's attribute table. 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. ExampleAddressing Information a Configuration File <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="http://cxf.apache.org/configuration/types" xmlns:jms="http://cxf.apache.org/transports/jms" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd"> <jms:conduit name="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit"> <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> </jms:conduit> </beans> Consumer Endpoint ConfigurationJMS 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 by both XML configuration and via WSDL. Using ConfigurationSpecifying the message typeYou can specify the message type supported by the consumer endpoint using a jms:runtimePolicy element that has a single attribute:
The following example shows a configuration entry for configuring a JMS consumer endpoint. Configuration for a JMS Consumer Endpoint <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="http://cxf.apache.org/configuration/types" xmlns:jms="http://cxf.apache.org/transports/jms" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd"> ... <jms:conduit name="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit"> <jms:address ... > ... </jms:address> <jms:runtimePolicy messageType="binary"/> ... </jms:conduit> ... </beans> The id on the jms:conduit is in the form of {WSDLNamespace}WSDLPortName.jms-conduit. This provides CXF with the information so that it can associate the configuration with your service's endpoint. Using WSDLThe 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 Endpoint ConfigurationJMS service endpoints have a number of behaviors that are configurable in the contract. These include:
Service endpoints can be configure in one of two ways:
Using ConfigurationSpecifying configuration dataUsing the jms:destination elements you can configure your service's endpoint. You can specify the service endpoint's behaviors using the jms:runtimePolicy element that has a the following attributes:
The following example shows a CXF configuration entry for configuring a JMS service endpoint. Configuration for a JMS Service Endpoint <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="http://cxf.apache.org/configuration/types" xmlns:jms="http://cxf.apache.org/transports/jms" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd"> ... <jms:destination name="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination"> <jms:address ... > ... </jms:address> ... <jms:runtimePolicy messageSelector="cxf_message_selector" useMessageIDAsCorrelationID="true" transactional="true" durableSubscriberName="cxf_subscriber" /> ... </jms:destination> ... </beans> Using WSDLService 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:
JMS Runtime ConfigurationIn 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 ConfigurationYou configure an endpoint's JMS session pool using the jms:sessionPoolConfig element. 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 following example shows an example of configuring the session pool for a CXF JMS service endpoint. JMS Session Pool Configuration <jms:destination name="{http://cxf.apache.org/jms_endpit}HelloWorldJMSPort.jms-destination"> ... <jms:sessionPool lowWaterMark="10" highWaterMark="5000" /> </jms:destination> The jms:sessionPool element can also be used within a jms:conduit. Consumer Specific Runtime ConfigurationThe JMS consumer configuration allows you to specify two runtime behaviors:
You use the jms:clientConfig element to set JMS consumer runtime behavior. This element's attributes, listed in the following table, specify the configuration values for consumer runtime behavior.
The following example shows a configuration fragment that sets the consumer endpoint's request lifetime to 500 milliseconds and its timeout value to 500 milliseconds. JMS Consumer Endpoint Runtime Configuration <jms:conduit name="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit"> ... <jms:clientConfig clientReceiveTimeout="500" messageTimeToLive="500" /> </jms:conduit> Service Specific Runtime ConfigurationThe JMS service configuration allows you to specify to runtime behaviors:
The jms:serverConfig element is used to specify the service runtime configuration. This element's attributes, listed below, specify the configuration values that control the service's runtime behavior.
The following example shows a configuration fragment that sets the service endpoint's response lifetime to 500 milliseconds and its durable subscription client identifier to jms-test-id. JMS Service Endpoint Runtime Configuration <jms:destination id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination"> <jms:address ... > ... </jms:address> <jms:serverConfig messageTimeToLive="500" durableSubscriptionClientId="jms-test-id" /> </jms:destination>
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache CXF Documentation > JMS Transport confluence