Typically, you configure the Messaging Service, including the JMSAdapter, in the messaging-config.xml file.
You configure the JMSAdapter individually for the destinations that use it, as the following example shows:
<adapters>
<adapter-definition id="jms"
class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
</adapters>
You perform most of the configuration of the JMSAdapter in the destination definition. Configure the adapter with the proper JNDI information and JMS ConnectionFactory information to look up the connection factory in JNDI.
The following example shows a destination that uses the JMSAdapter:
<destination id="chat-topic-jms">
<properties>
...
<jms>
<destination-type>Topic</destination-type>
<message-type>javax.jms.TextMessage</message-type>
<connection-factory>jms/flex/TopicConnectionFactory</connection-factory>
<destination-jndi-name>jms/topic/flex/simpletopic</destination-jndi-name>
<delivery-mode>NON_PERSISTENT</delivery-mode>
<message-priority>DEFAULT_PRIORITY</message-priority>
<preserve-jms-headers>"true"</preserve-jms-headers>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<connection-credentials username="sampleuser" password="samplepassword"/>
<max-producers>1</max-producers>
</jms>
</properties>
...
<adapter ref="jms"/>
</destination>
The JMSAdapter accepts the following configuration properties. For more specific information about JMS, see the Java Message Service specification or your application server documentation.
|
Property |
Description |
|---|---|
| acknowledge-mode |
Not used with JMSAdapter. |
| connection-credentials |
(Optional) The username and password used while creating the JMS connection for example: <connection-credentials username="sampleuser" password="samplepassword"/> Use only if JMS connection level authentication is being used. |
| connection-factory |
Name of the JMS connection factory in JNDI. |
| delivery-mode |
JMS DeliveryMode for producers. The valid values are PERSISTENT and NON_PERSISTENT. The PERSISTENT mode specifies that all sent messages be stored by the JMS server, and then forwarded to consumers. This configuration adds processing overhead but is necessary for guaranteed delivery. The NON_PERSISTENT mode does not require that messages be stored by the JMS server before forwarding to consumers, so they can be lost if the JMS server fails while processing the message. This setting is suitable for notification messages that do not require guaranteed delivery. |
| delivery-settings/mode |
(Optional) Specifies the message delivery mode used to deliver messages from the JMS server. If you specify async mode, but the application server cannot listen for messages asynchronously (that is javax.jms.MessageConsumer.setMessageListener is restricted), or the application server cannot listen for connection problems asynchronously (for example, javax.jms.Connection.setExceptionListener is restricted), you get a configuration error asking the user to switch to sync mode. The default value is sync. |
| delivery-settings/sync- receive-interval-millis |
(Optional) Default value is 100. The interval of the receive message calls. Only available when the mode value is sync. |
| delivery-settings/sync- receive-wait-millis |
(Optional) Default value is 0 (no wait). Determines how long a JMS proxy waits for a message before returning. Using a high sync-receive-wait-millis value along with a small thread pool can cause messages to back up if many proxied consumers are not receiving a steady flow of messages. Only available when the mode value is sync. |
| destination-jndi-name |
Name of the destination in the JNDI registry. |
| destination-type |
(Optional) Type of messaging that the adapter is performing. Valid values are topic for publish-subscribe messaging and queue for point-to-point messaging. The default value is topic. |
| initial-context-environment |
A set of JNDI properties for configuring the InitialContext used for JNDI lookups of your ConnectionFactory and Destination. Lets you use a remote JNDI server for JMS. For more information, see Using a remote JMS provider. |
| max-producers |
The maximum number of producer proxies that a destination uses when communicating with the JMS server. The default value is 1, which indicates that all clients using the destination share the same connection to the JMS server. |
| message-priority |
JMS priority for messages that producers send. The valid values are DEFAULT_PRIORITY or an integer value indicating the priority. The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. Additionally, clients should consider priorities 0-4 as gradations of normal priority, and priorities 5-9 as gradations of expedited priority. |
| message-type |
Type of message to use when transforming Flex messages into JMS messages. Supported types are javax.jms.TextMessage and javax.jms.ObjectMessage. If the client-side Publisher component sends messages as objects, set the message-type to javax.jms.ObjectMessage. |
| message-type |
The javax.jms.Message type which the adapter uses for this destination. Supported types are javax.jms.TextMessage and javax.jms.ObjectMessage. |
| preserve-jms-headers |
(Optional) Defaults to true. Determines whether the adapter preserves all standard JMS headers from JMS messages to LiveCycle Data Services ES messages. Every JMS message has a set of standard headers: JMSDestination, JMSDeliveryMode, JMSMessageID, JMSTimestamp, JMSExpiration, JMSRedelivered, JMSPriority, JMSReplyTo, JMSCorrelationID, and JMSType. The JMS server sets these headers when the message is created and they are passed to LiveCycle Data Services ES. LiveCycle Data Services ES converts the JMS message into a LiveCycle Data Services ES message and sets JMSMessageID and JMSTimestamp on the LiveCycle Data Services ES message as messageId and timestamp, but the rest of the JMS headers are ignored. Setting the preserve-jms-headers property to true preserves all of the headers. |
When a destination specifies a <destination-type> of topic for the JMSAdapter, you can set the durable property in the server definition. When true, the durable property specifies that messages are saved in a durable message store to ensure that they survive connection outages and reach destination subscribers. The default value is false.
The following example sets the durable property to true:
<server>
<durable>true</durable>
</server>
In many cases, the JMS server is embedded in your J2EE server. However, you can also interact with a JMS server on a remote computer accessed by using JNDI.
You can use JMS on a remote JNDI server by configuring the optional initial-context-environment element in the jms section of a message destination that uses the JMSAdapter. The initial-context-environment element takes property subelements, which in turn take name and value subelements. To establish the desired JNDI environment, specify the javax.naming.Context constant names and corresponding values in the name and value elements, or specify String literal names and corresponding values.
The bold-faced code in the following example is an initial-context-environment configuration:
<destination id="chat-topic-jms">
<properties>
...
<jms>
<destination-type>Topic</destination-type>
<message-type>javax.jms.TextMessage</message-type>
<connection-factory>jms/flex/TopicConnectionFactory</connection-factory>
<destination-jndi-name>jms/topic/flex/simpletopic</destination-jndi-name>
<delivery-mode>NON_PERSISTENT</delivery-mode>
<message-priority>DEFAULT_PRIORITY</message-priority>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<!-- (Optional) JNDI environment. Use when using JMS on a remote JNDI server. -->
<initial-context-environment>
<property>
<name>Context.SECURITY_PRINCIPAL</name>
<value>anonymous</value>
</property>
<property>
<name>Context.SECURITY_CREDENTIALS</name>
<value>anonymous</value>
</property>
<property>
<name>Context.PROVIDER_URL</name>
<value>http://{server.name}:1856</value>
</property>
<property>
<name>Context.INITIAL_CONTEXT_FACTORY</name>
<value>fiorano.jms.runtime.naming.FioranoInitialContextFactory</value>
</property>
</initial-context-environment>
</jms>
</properties>
...
<adapter ref="jms"/>
</destination>
Flex treats name element values that begin with the text "Context." as constants defined by javax.naming.Context and verifies that the Context class defines the constants that you specify. Some JMS providers also allow custom properties to be set in the initial context. You can specify these properties by using the string literal name and corresponding value that the provider requires. For example, the FioranoMQ JMS provider configures failover to back up servers with the following property:
<property>
<name>BackupConnectURLs</name>
<value>http://backup-server:1856;http://backup-server-2:1856</value>
</property>
If you do not specify the initial-context-environment properties in the jms section of a destination definition, the default JNDI environment is used. The default JNDI environment is configured in a jndiprovider.properties application resource file and or a jndi.properties file.
Naming conventions across JNDI providers for topic connection factories and destinations can vary. Depending on your JNDI environment, the connection-factory and destination-jndi-name elements must correctly reference the target named instances in the directory. Include the client library JAR files for your JMS provider in the WEB-INF/lib directory of your web application, or in another location from which the class loader loads them. Even when using an external JMS provider, LiveCycle Data Services ES uses the connection-factory and destination-jndi-name configuration properties to look up the necessary connection factory and destination instances.
Section 6.6 of the J2EE 1.4 specification limits some of the JMS APIs that can be used in a J2EE environment. The following table lists the restricted APIs that are relevant to the JMSAdapter and the implications of the restrictions.
|
API |
Implication of restriction |
Alternative |
|---|---|---|
|
javax.jms.MessageConsumer.get/setMessageListener |
No asynchronous message delivery |
Set the mode attribute of the delivery-settings configuration property to sync. |
|
javax.jms.Connection.setExceptionListener |
No notification of connection problems |
Set the mode attribute of the delivery-settings configuration property to sync. |
|
javax.jms.Connection.setClientID |
No durable subscribers |
Set the durable configuration property to false. |
|
javax.jms.Connection.stop |
Not an important implication |
None |
The JMSAdapter handles these restrictions by doing the following:
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/lcds/jms_messaging_3.html