High Quality JMS & AMQP Messaging.

Inbound Configuration

Message Endpoint

Messages are delivered to message endpoints in J2EE 1.4. These endpoints are message-driven beans (MDBs) which implement the interface specific to the messaging provider. MDBs which receive JMS messages will implement the javax.jms.MessageListener interface just as with J2EE 1.3.

Endpoint Activation

A message enpoint is activated during the deployment of a MDB. The MDB deployment descriptor (ejb-jar.xml) contains a section called "activation-config" with properties specific to the messaging provider. This activation configuration is used from the application server to activate a message endpoint. Once an endpoint is active, it is ready to receive messages.

How the SwiftMQ Resource Adapter implements Message Inflow

The SwiftMQ RA utilizes Application Server Facilities (ASF, JMS Spec. Chapter 8) to realize message inflow. The following resources are created per message endpoint:

If you have 2 message endpoints, you have 2 connection consumer and 2 server session pools.

The server session pool is our implementation (in prev. J2EE version it was an implementation of the application server). The pool consists of a configurable number of server sessions (javax.jms.ServerSession) which are also our implementation.

Both the connection consumer and the server session pool are configured by activation configiration properties in the MDB's ejb-jar.xml file.

Activation Configuration Properties of the SwiftMQ Resource Adapter

The following table lists the properties which can be configured for SwiftMQ's RA (change for Connector 1.6 Resource Adapter: All property names start with a lowercase character):

Property Name (1.5) Property Name (1.6) Type Mandatory Default Value
ConnectionFactoryName connectionFactoryName java.lang.String Yes null
Destination destination java.lang.String Yes null
DestinationType destinationType java.lang.String No "javax.jms.Topic"
SubscriptionDurability subscriptionDurability java.lang.String No "NonDurable"
Username username java.lang.String No anonymous
Password password java.lang.String No null
ClientId clientId java.lang.String Durable subscribers: Yes null
DurableName durableName java.lang.String Durable subscribers: Yes null
MessageSelector messageSelector java.lang.String No null
Transacted transacted java.lang.String No "false"
Xa xa java.lang.String No "false"
DeliveryOption deliveryOption java.lang.String No "A"
MaxPoolSize maxPoolSize java.lang.String No "10"
MaxMessages maxMessages java.lang.String No "1"

ConnectionFactoryName

The name of SwiftMQ's JMS connection factory to use. Remember that SwiftMQ's RA has a JNDI context, pointing to the SwiftMQ router. The value of this property is used to lookup the connection factory there. If the RA uses an external router, simply use the predefined connection factory like "ConnectionFactory". If a SwiftMQ router is started intraVM, use an intraVM connection factory like "IVMConnectionFactory".

Destination

The name of the SwiftMQ destination (queue or topic) where the connection consumer is created on. The name is used to lookup the destination from SwiftMQ's JNDI:

DestinationType

The type of the destination. Possible values are "javax.jms.Topic" and "javax.jms.Queue".

SubscriptionDurability

For pub/sub only. Specified the durability of a subscription. Possible values are "Durable" and "NonDurable".

Username

The SwiftMQ user name. Only required if authentication is enabled in SwiftMQ's Authentication Swiftlet.

Password

The user's password. Only required if authentication is enabled in SwiftMQ's Authentication Swiftlet.

ClientId

The JMS client id. This is only required for pub/sub and when using durable subscribers.

DurableName

The durable subscription name. This is only required for pub/sub and when using durable subscribers.

MessageSelector

An optional message selector to filter messages out of the destination.

Transacted

Specifies whether the message delivery should be done transacted or non-transacted. Possible values are "true" and "false".

Xa

Specifies whether the message delivery should be done with XA. Possible values are "true" and "false". If set to "true", the property "Transacted" must also be "true". The following table lists possible settings and their consequences:

Transacted Xa Meaning
true false Transacted delivery, local transactions.
true true Transacted delivery, XA transactions.
false false Non-transacted delivery with auto-acknowledge.
true false Invalid setting.

DeliveryOption

This is only required for XA transactions.

The Connector 1.5 specification mentions 2 possible ways to handle the en/delistment of the XAResource. First is to rely on the application server to en/delist the XAResource within a call of the message endpoints "onMessage()" method. We call this option "A".

The other method is to call the methods "beforeDelivery()" and "afterDelivery()" of the message endpoint from the RA and trust the message endpoint takes care of en/delistment within that calls. This is option "B".

There should be no difference in the result with both options. We made this configurable for the only reason to workaround bugs in application servers. So if "A" doesn't work, use "B".

MaxPoolSize

This defines the maximum size of the server session pool. The greater the size the more MDBs can be served concurrently but the more resources (threads) are used.

MaxMessages

This defines the maximum number of messages to load into a single server session. For example, if the connection consumer has 10 messages available and this size is 5, it uses 2 server sessions (given the MaxPoolSize is > 1 and there are 2 free server sessions available), each loaded with 5 messages which are processed in sequential order. After all messages have been processed, the server session adds itself into the server session pool.

Example Deployment Descriptor

The following example defines a message endpoint (MDB) which is a durable subscriber on topic "testopic" with client id "Testclient" and durable name "dur1". A message selector "msgno between 20 and 30" is used to filter messages. The connection factory "plainsocket@router1" is used. Delivery is done with container managed transactions and XA by using delivery option "B". The server session pool has an upper limit of 20 server session where each can be loaded with up to 10 messages.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved. -->
<ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
  <display-name>SampleEndpoint</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>SampleEndpoint</display-name>
      <ejb-name>SampleEndpointB</ejb-name>
      <ejb-class>mdb.withsend.SampleEndpointBean</ejb-class>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <activation-config>
        <activation-config-property>
          <activation-config-property-name>
            DestinationType
          </activation-config-property-name>
          <activation-config-property-value>
            javax.jms.Topic
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            Destination
          </activation-config-property-name>
          <activation-config-property-value>
            testtopic
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            SubscriptionDurability
          </activation-config-property-name>
          <activation-config-property-value>
            Durable
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            ClientId
          </activation-config-property-name>
          <activation-config-property-value>
            Testclient
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            DurableName
          </activation-config-property-name>
          <activation-config-property-value>
            dur1
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            MessageSelector
          </activation-config-property-name>
          <activation-config-property-value>
            msgno between 20 and 30
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            ConnectionFactoryName
          </activation-config-property-name>
          <activation-config-property-value>
            plainsocket@router1
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            Transacted
          </activation-config-property-name>
          <activation-config-property-value>
            true
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            Xa
          </activation-config-property-name>
          <activation-config-property-value>
            true
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            DeliveryOption
          </activation-config-property-name>
          <activation-config-property-value>
            B
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            MaxPoolSize
          </activation-config-property-name>
          <activation-config-property-value>
            20
          </activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>
            MaxMessages
          </activation-config-property-name>
          <activation-config-property-value>
            10
          </activation-config-property-value>
        </activation-config-property>
      </activation-config>
    </message-driven>
  </enterprise-beans>
</ejb-jar>