Configuring the JMS adapter

You use the JMS adapter to subscribe to JMS topics or queues configured on an implementation of the Java Message Service. This adapter lets Java JMS publishers and subscribers share the same destination as a Flex client application. Java code can publish messages to the Flex application, and Java code can respond to messages that the Flex application publishes.

You configure the JMS adapter individually for the destinations that use it. You must configure the adapter with the proper Java Naming and Directory Interface (JNDI) information and JMS ConnectionFactory information to look up the connection factory in JNDI, create a connection from it, create a session on behalf of the Flex client, and create a publisher and subscribers on behalf of the Flex client.

The following example shows a destination that uses the JMS adapter:

...
<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>
            <destination-name>FlexTopic
            </destination-name>
            <delivery-mode>NON_PERSISTENT</delivery-mode>
            <message-priority>DEFAULT_PRIORITY</message-priority>
            <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
            <transacted-sessions>false</transacted-sessions>
    <!-- (Optional) JNDI environment. Use when using JMS on a remote JNDI server. Used to specify the JNDI environment to access an external JMS provider. -->
    <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>
...

The JMS adapter accepts the following configuration properties. For more specific information about JMS, see the Java Message Service specification or your application server documentation.

Property

Description

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.

message-type

Type of the 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, you must set the message-type to javax.jms.ObjectMessage.

connection-factory

Name of the JMS connection factory in JNDI.

destination-jndi-name

Name of the destination in the JNDI registry.

destination-name

(Optional) Name of the destination in JMS. The default value is the Flex destination id.

delivery-mode

JMS DeliveryMode for producers.

The valid values are PERSISTENT and NON_PERSISTENT. The PERSISTENT mode causes all sent messages to be stored by the JMS server and then forwarded to consumers. This 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 may be lost if the JMS server fails while processing the message; this setting is suitable for notification messages that do not require guaranteed delivery.

message-priority

JMS priority for messages that Flex producers send.

The valid values are DEFAULT_PRIORITY or an integer value indicating what the priority should be. 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.

acknowledge-mode

JMS message acknowledgment mode. The valid values are AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, and CLIENT_ACKNOWLEDGE.

transacted-sessions

JMS session transaction mode.

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.

Subtopics

Using a remote JMS provider

Flex 2.01

Take a survey