THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Wiki Markup |
---|
Chapter 1. Using the Java Messaging System Table of Contents JMS Namespaces ................................................................................................................. 1 Basic Endpoint Configuration ................................................................................................ 2 Using WSDL .............................................................................................................. 2 Using Configuration ..................................................................................................... 4 Consumer Endpoint Configuration .......................................................................................... 5 Using Configuration ..................................................................................................... 6 Using WSDL .............................................................................................................. 7 Service Endpoint Configuration .............................................................................................. 7 Using Configuration ..................................................................................................... 7 Using WSDL .............................................................................................................. 9 JMS Runtime Configuration .................................................................................................. 9 Base Runtime Configuration .......................................................................................... 9 Consumer Specific Runtime Configuration ..................................................................... 10 Service Specific Runtime Configuration ......................................................................... 11 Celtix Enterpriseh1.Using the Java Messaging System CXF provides a transport plug-in that enables endpoints to use Java Messaging System (JMS) queues and topics. Celtix EnterpriseCXF'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 CeltixCXF Enterprise has established a connection to a JMS provider, Celtix EnterpriseCXF supports the passing of messages packaged as either a JMS {{ObjectMessage}} or a JMS {{TextMessage}}. h2.JMS Namespaces h3.WSDL Namespace 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 shown in Example 1.1, "JMS Extension Namespace" below to the definitions element of your contract. Example 1.1. {code:title=JMS Extension Namespace} xmlns:jms="http://cxf.apache.org/transports/jms" {code} h3.Configuration Namespaces The CeltixCXF Enterprise JMS endpoint configuration properties are specified under two namespaces: •* {{http://cxf.apache.org/transports/jmscontains}} the elements used to define the basic JMS port configuration. •* {{http://cxf.apache.org/transports/jms/jms-conf}} contains element used for configuring the runtime components of the JMS transport. 1 In order to use the JMS configuration properties you will need to add the lines shown in Example 1.2, "JMS Configuration Namespaces"below to the {{beans}} element of your configuration. Example 1.2. {code:title=JMS Configuration Namespaces} xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:jms-conf="http://cxf.apache.org/transports/jms/jms-conf" {code} h2.Basic Endpoint 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 •* Configuratoin h3.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. h4.The address element The basic configuration for a JMS endpoint is done by using a {{jms:address}} element as the child of your service's {{port}} element. The {{jms:address}} element uses the attributes described in Table 1.1, "JMS Endpoint Attributes"below to configure the connection to the JMS broker. Table 1.1. JMS Endpoint Attributes Attribute Description destinationStyle ||Attribute||Description|| |{{destinationStyle}}|Specifies if the JMS destination is a JMS queue or a JMS topic.| |{{jndiConnectionFactoryName}}|Specifies the JNDI name bound to the JMS connection factory to use when connecting to the JMS destination. jndiConnectionFactoryName | |{{jndiDestinationName}}|Specifies the JNDI name bound to the JMS destination to which requests are sent. jndiDestinationName | |{{jndiReplyDestinationName}}|Specifies the JNDI name bound to the JMS destinations where replies are sent. This attribute allows you to use a user defined destination for replies. For more details see the section called "Using a named reply destination". jndiReplyDestinationName connectionUserName | |{{connectionUserName}}|Specifies the username to use when connecting to a JMS broker.| connectionPassword |{{connectionPassword}}|Specifies the password to use when connecting to a JMS broker.| h4. The JMSNamingProperties element To increase interoperability with JMS and JNDI providers, the {{jms:address}} element has a child element, {{jms:JMSNamingProperties}}, that allows you to specify the values used to populate the properties used when connecting to the JNDI provider. The {{jms:JMSNamingProperties}} element has two 2 Using the Java Messaging System attributes: {{name}} and {{value}}. The {{name}} attribute specifies the name of the property to set. The {{value}} attribute specifies the value for the specified property. The {{jms:JMSNamingProperties}} element can also be used for specification of provider specific properties. The following is a list of common JNDI properties that can be set: 1.# {{java.naming.factory.initial}} 2.# {{java.naming.provider.url}} 3.# {{java.naming.factory.object}} 4.# {{java.naming.factory.state}} 5.# {{java.naming.factory.url.pkgs}} 6.# {{java.naming.dns.url}} 7.# {{java.naming.authoritative}} 8.# {{java.naming.batchsize}} 9.# {{java.naming.referral}} 10.# {{java.naming.security.protocol}} 11.# {{java.naming.security.authentication}} 12.# {{java.naming.security.principal}} 13.# {{java.naming.security.credentials}} 14.# {{java.naming.language}} 15.# {{java.naming.applet}} For more details on what information to use in these attributes, check your JNDI provider's documentation and consult the Java API reference material. h4.Using a named reply destination By default, Celtix EnterpriseCXF endpoints using JMS create a temporary queue for sending replies back and forth. You can change this behavior by setting the {{jndiReplyDestinationName}} attribute in the endpoint's contract. A client endpoint will listen for replies on the specified destination and it will specify the value of the attribute in the {{ReplyTo}} field of all outgoing requests. A service endpoint will use the value of the {{jndiReplyDestinationName}} attribute as the location for placing replies if there is no destination specified in the request's {{ReplyTo}} field. Example Example 1.3, "JMS WSDL Port Specification" The following example shows an example of a JMS WSDL port specification. 3 Using the Java Messaging System Example 1.3. {code:title=JMS WSDL Port Specification} <service name="JMSService"> <port binding="tns:Greeter_SOAPBinding" name="SoapPort"> <jms:address jndiConnectionFactoryName="ConnectionFactory" <jms:address jndiConnectionFactoryName="ConnectionFactory" jndiDestinationName="dynamicQueues/test.Celtix.jmstransport" > <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.activemq.jndi.ActiveMQInitialContextFactory" /> <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61616" /> </jms:address> </port> </service> {code} h3.Using Configuration In addition to using the WSDL file to specify the connection information for a JMS endpoint, you can supply it in the endpoint's configuration file. The information in the configuration file will override the information in the endpoint's WSDL file. h4.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 h3.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. Its attributes are listed}} element used in Table 1.1, "JMS Endpoint Attributes". 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. Example Example 1.4, "Addressing Information in a Celtix Enterprise Configuration File"The following example shows a CeltixCXF Enterprise configuration entry for configuring the addressing information for a JMS consumer endpoint. 4 Using the Java Messaging System Example 1.4. endpoint. {code:title=Addressing Information in a Celtix Enterprise 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" 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 id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit-base" class="org.apache.cxf.transport.jms.base.JMSTransportBaseConfigBean"> <property name="addressPolicy"> <value> <jms:address destinationStyle="queue" <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" <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61616"/> </jms:address> </value> </property> </bean> </beans> {code} h2.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 Celtix Enterprise consumers, the JMS application is responsible for interpreting the message and the formatting information. For example, if the Celtix Enterprise 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 5 Using the Java Messaging System • WSDL Tip The recommended method is to place the consumer endpoint specific information into the Celtix Enterprise configuration file for the endpoint. Using Configuration Specifying the message type C o n s u m e r e n d p o i n t c o n fi g u r a t i o n i s s p e c i fi e d u s i n g 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, that has a single attribute: Table 1.2. JMS Client Configuration Properties Specifies how the message data will be packaged as a JMS message. text specifies that the data will be packaged as a TextMessage. binary specifies that the data will be packaged as an ObjectMessage. messageType Example Example 1.5, "Configuration for a JMS Consumer Endpoint" shows a configuration entry for configuring a JMS consumer endpoint. Example 1.5. 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" 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 id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit" class="org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean"> <property name="client"> <value> <jms:client messageType="binary"/> </value> </property> ... </bean> ... </beans> 6 Using the Java Messaging System Specifying address information 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. See the section called "Using Configuration". 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: Table 1.3. JMS Client WSDL Extensions Specifies how the message data will be packaged as a JMS message. text specifies that the data will be packaged as a TextMessage. binary specifies that the data will be packaged as an ObjectMessage. messageType Service Endpoint Configuration JMS service endpoints have a number of behaviors that are configurable in the contract. These include: • how messages are correlated • the use of durable subscriptions • if the service uses local JMS transactions • the message selectors used by the endpoint Service endpoints can be configure in one of two ways: • Configuration • WSDL Tip The recommended method is to place the service endpoint specific information into the Celtix Enterprise configuration file for the endpoint. Using Configuration Specifying configuration data S e r v i c e e n d p o i n t c o n fi g u r a t i o n i s s p e c i fied 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: 7 Using the Java Messaging System Table 1.4. JMS Service Endpoint Configuration Attribute Description Specifies whether the JMS broker will use the message ID to correlate messages. The default is false. useMessageIDAsCorrealationID durableSubscriberName 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 selectors, see the JMS 1.1 specification. messageSelector Specifies whether the local JMS broker will create transactions around message processing. The default is false. Currently, this is not supported by the runtime. transactional Example Example 1.6, "Configuration for a JMS Service Endpoint" shows a Celtix Enterprise configuration entry for configuring a JMS service endpoint. Example 1.6. 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" 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 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. See the section called "Using Configuration". 8 Using the Java Messaging System 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: Table 1.5. JMS Service Endpoint WSDL Extensions Attribute Description Specifies whether JMS will use the message ID to correlate messages. The default is false. useMessageIDAsCorrealationID durableSubscriberName 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 selectors, see the JMS 1.1 specification. messageSelector Specifies whether the local JMS broker will create transactions around message processing. The default is false. Currently, this is not supported by the runtime. transactional 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. 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 9 Using the Java Messaging System endpoint is garunteed 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 property takes a single jms-conf:sessionPoolConfig element. The jms-conf:sessionPoolConfig element's attributes, listed in Table 1.6, "Attributes for Configuring the JMS Session Pool", specify the high and low water marks for the endpoint's JMS session pool. Table 1.6. Attributes for Configuring the JMS Session Pool Attribute Description Specifies the minimum number of JMS sessions pooled by the endpoint. The default is 20. lowWaterMark Specifies the maximum number of JMS sessions pooled by the endpoint. The default is 500. highWaterMark Example Example 1.7, "JMS Session Pool Configuration" shows an example of configuring the session pool for a Celtix Enterprise JMS service endpoint. Example 1.7. JMS Session Pool Configuration <bean 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:sessionPoolConfig lowWaterMark="10" highWaterMark="5000" /> </value> </property> </bean> Consumer Specific Runtime Configuration The JMS consumer configuration allows you to specify two runtime behaviors: • 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 confi g u r e c o n s u m e r r u n t i m e b e h av i o r u s i n g t h e org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean. Note This is the same configuration bean that is used to configure the message type used by a JMS consumer endpoint. 10 Using the Java Messaging System 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 Table 1.7, "JMS Consumer Runtime Configuration Attributes", specify the configuration values for consumer runtime behavior. Table 1.7. JMS Consumer Runtime Configuration Attributes Attribute Description Specifies the amount of time, in milliseconds, that the endpoint will wait for a response before it timesout and issues an exception. The default value is 2000. clientReceiveTimeout Specifies the amount of time, in milliseconds, that a request can remain unrecieved before the JMS broker can delete it. The default value is 0 which specifies that the message can never be deleted. messageTimeToLive Example Example 1.8, "JMS Consumer Endpoint Runtime Configuration" shows a configuraiton fragment that sets the consumer endpoint's request lifetime to 500 milliseconds and its timeout value to 500 milliseconds. Example 1.8. JMS Consumer Endpoint Runtime Configuration <bean id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-conduit" class="org.apache.cxf.transport.jms.conduit.JMSConduitConfigBean"> ... <property name="clientConfig"> <value> <jms-conf:clientConfig clientReceiveTimeout="500" messageTimeToLive="500" /> </value> </property> </bean> Service Specific Runtime Configuration The JMS service configuration allows you to specify to runtime behaviors: • 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 You configure JMS service runtime behavior using the org.apache.cxf.transport.jms.destination.JMSDestinationConfigBean. Note This is the same configuration bean that is used to configure the endpoint properties of a JMS service endpoint. 11 Using the Java Messaging System Configuration property The serverConfig property is used to specify the service runtime configuration. It takes a single jms-conf:serverConfig element. This element's attributes, listed in Table 1.8, "JMS Service Runtime Configuration Attributes", specify the configuration values that control the service's runtime behavior. Table 1.8. JMS Service Runtime Configuration Attributes Attribute Description Specifies the amount of time, in milliseconds, that a response can remain unread before the JMS broker is allowed to delete it. The default is 0 which specifies that the message can live forever. messageTimeToLive Specifies the client identifier the endpoint uses to create and access durable subscriptions. durableSubscriptionClientId Example Example 1.9, "JMS Service Endpoint Runtime Configuration" 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. {code: title=JMS Service Endpoint Runtime Configuration} <bean id="{http://cxf.apache.org/jms_endpt}HelloWorldJMSPort.jms-destination" class="org.apache.cxf.transport.jms.destination.JMSDestinationConfigBean"> ... <property name="serverConfig"> <value> <jms-conf:serverConfig messageTimeToLive="500" durableSubscriptionClientId="jms-test-id" /> </value> </property> </bean> {code} |