Connection factories are configured using parameters in the transport description in axis2.xml. The syntax is the same for the transport listener and sender. For example, the following configuration sets up the JMS listener with three connection factories:
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
</parameter>
<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
</parameter>
<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
</parameter>
</transportReceiver>If a connection factory named default (as shown above) is defined, this would be used for services which does not explicitly specify the connection factory that should be used. The services.xml of a service should indicate the connection factory and the destination name to be associated with. If a destination is not specified, the implementation would create a JMS Queue with the service name. The JMS destination should ideally be created and administered through the JMS provider utilities.
For the JMS sender, only the outer element is different:
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender">
...
</transportSender>As explained below, for the JMS sender configuration it is not mandatory (but recommended) to specify connection factories.
The parameters that may appear in a connection factory configuration are defined as follows:
java.naming.factory.initialjava.naming.provider.urltransport.jms.ConnectionFactoryJNDINamejava.naming.security.principaljava.naming.security.credentialstransport.Transactionalitytransport.UserTxnJNDINametransport.CacheUserTxntransport.jms.SessionTransactedtransport.jms.SessionAcknowledgementtransport.jms.ConnectionFactoryTypetransport.jms.JMSSpecVersiontransport.jms.UserNametransport.jms.Passwordtransport.jms.DefaultReplyDestinationtransport.jms.DefaultReplyDestinationTypetransport.jms.MessageSelectortransport.jms.SubscriptionDurabletransport.jms.DurableSubscriberNametransport.jms.PubSubNoLocaltransport.jms.CacheLeveltransport.jms.ReceiveTimeouttransport.jms.ConcurrentConsumerstransport.jms.MaxConcurrentConsumerstransport.jms.IdleTaskLimittransport.jms.MaxMessagesPerTasktransport.jms.InitialReconnectDurationtransport.jms.ReconnectProgressFactortransport.jms.MaxReconnectDurationEvery deployed service for which the JMS transport is enabled will be associated with a destination (queue or topic) according to the following rules:
transport.jms.Destination parameter, its value is interpreted as the JNDI name of the destination.At the same time, the connection factory is determined by looking at the service parameter transport.jms.ConnectionFactory. If this parameter is not set, the default value default is assumed. The value of this parameter is interpreted as a logical identifier for the connection factory configuration defined in the transport configuration (see above).
It follows that JMS destinations are statically bound to services. Therefore the transport always predispatches incoming messages to the service the destination is bound to.
The message is dispatched to an operation according to the following rules:
Operation. If this parameter is not present, the default value urn:mediate is assumed.In addition, if the JMS message has a property named SOAPAction, the value of this property is interpreted as the SOAP action.
Apart from the following list most of the parameters defined in the global connection factory can be overriden at the service level as well
transport.jms.ConnectionFactory (Optional)axis2.xml) to be used to listen for messages for this service.transport.jms.Destination (Optional)transport.jms.DestinationType (Optional)transport.jms.ReplyDestination (Optional)transport.jms.ContentType (Optional)<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<jmsProperty>ctype</jmsProperty>
<default>text/xml</default>
</rules>
</parameter>The rules are evaluated in turn until the first matches. The following rule types are defined:
jmsPropertybytesMessagetextMessage<bytesMessage>binary/octet-stream</bytesMessage>defaultIf none of the rules matches, an error is triggered and the message is not processed. The default value for this property corresponds to the following set of rules:
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>Content-Type</jmsProperty>
<bytesMessage>application/octet-stream</bytesMessage>
<textMessage>text/plain</textMessage>
</rules>
</parameter>This choice preserves compatibility with previous versions of the JMS transport. Note however that Content-Type is not a valid JMS property name and will not work with some JMS providers.
Wrapper (Optional)text/plain and application/octet-stream (which are the respective default content types for JMS text and binary messages).Sample services.xml:
<service name="echo">
<transports>
....
<transport>jms</transport>
</transports>
...
<parameter name="transport.jms.ConnectionFactory" locked="true">myTopicConnectionFactory</parameter>
<parameter name="transport.jms.Destination" locked="true">dynamicTopics/something.TestTopic</parameter>
</service>For incoming messages, the transport listener will make the following properties available in the message context:
TRANSPORT_HEADERSEndpoint references for the JMS transport must have the following form:
jms-epr = "jms:/" jms-dest [ "?" param *( [ "&" param ] ) ] param = param-name "=" param-value
jms-dest is the JNDI name of the destination to send the message to. The parameters are defined as follows:
transport.jms.ConnectionFactory (Optional)axis2.xml) to be used to send messages to the endpoint.transport.jms.ContentTypePropertyAll the above listed parameters under the connection factory configuration are applied to the JMS EPR as well, apart from these.
If no connection factory definition is explicitly specified using the transport.jms.ConnectionFactory parameter, the JMS sender will check if the transport configuration contains a connection factory compatible with the other settings specified in the endpoint URL (transport.jms.ConnectionFactoryJNDIName, java.naming.factory.initial, java.naming.provider.url, java.naming.security.principal and java.naming.security.credentials). If a matching configuration is found, the sender will reuse the cached JMS objects related to that configuration. Otherwise it will execute the JNDI lookup and open a new connection. In that case the connection will be closed immediately after sending the message.
For outgoing messages, the transport sender will recognize the following message context properties:
TRANSPORT_HEADERSNote that all the properties are optional.
transport.jms.ContentType service parameter.transport.jms.ContentTypeProperty message context property or the transport.jms.ContentTypeProperty parameter of the endpoint reference.