Library Link To Toggle Frames Print Feedback

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:

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.

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 2.1, “JMS Endpoint Attributes” to configure the connection to the JMS broker.

Table 2.1. JMS Endpoint Attributes

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.
jndiDestinationName Specifies the JNDI name bound to the JMS destination to which requests are sent.
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 Using a named reply destination.
connectionUserName Specifies the user name to use when connecting to a JMS broker.
connectionPassword Specifies the password to use when connecting to a JMS broker.

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 attributes: name and value. name specifies the name of the property to set. value attribute specifies the value for the specified property. 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.

Using a named reply destination

By default, Celtix Enterprise 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 2.1, “JMS WSDL Port Specification” shows an example of a JMS WSDL port specification.

Example 2.1. JMS WSDL Port Specification

<service name="JMSService">
  <port binding="tns:Greeter_SOAPBinding" name="SoapPort">
    <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>

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.

Configuration elements

You configure a JMS endpoint using one of the following configuration elements:

  • jms:conduitThe jms:conduit element contains the configuration for a consumer endpoint. It has one attribute, id, whose value takes the form {WSDLNamespace}WSDLPortName.jms-conduit.

  • jms:destinationThe jms:destination element contains the configuration for a provider endpoint. It has one attribute, id, whose value takes the form {WSDLNamespace}WSDLPortName.jms-destination.

The address element

JMS 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 Table 2.1, “JMS Endpoint Attributes”. 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.

Example

Example 2.2, “Addressing Information in a Celtix Enterprise Configuration File” shows a Celtix Enterprise configuration entry for configuring the addressing information for a JMS consumer endpoint.

Example 2.2. 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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
<jms:conduit id="{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>