Version 8

    SwiftMQ inbound resource adapter for MDB

     

    SwiftMQ provide a JCA 1.5 resource that allows JMS message delivery to an MDB. The attached example ant project shows how to deploy such an MDB.

     

    ejb-jar.xml

     

    The ejb-jar xml contains the activation-config.

     

    NOTE: these properties could equally go in jboss.xml if you want to avoid

    polluting ejb-jar.xml with vendor specific properties.

     

    <?xml version="1.0" encoding="UTF-8"?>
    
    <ejb-jar 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"
             version="2.1">
    
       <enterprise-beans>
          <message-driven >
             <ejb-name>test/mdb</ejb-name>
             <ejb-class>test.mdb.TestMDBBean</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.Queue
              </activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
              <activation-config-property-name>
                Destination
              </activation-config-property-name>
              <activation-config-property-value>
                testqueue
              </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>
                ConnectionFactory
              </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>
                1
              </activation-config-property-value>
            </activation-config-property>
          </activation-config>
        </message-driven>
      </enterprise-beans>
    </ejb-jar>
    

     

    jboss.xml

     

    Here we define jboss specific stuff. There are two main items:

    • We define we want to use the jca 1.5 message inflow container

    • We tell jboss which rar will provide the inflow

     

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
    
    <jboss>
       <enterprise-beans>
          <message-driven>
             <ejb-name>test/mdb</ejb-name>
             <invoker-bindings>
               <invoker>
                  <invoker-proxy-binding-name>message-inflow-driven-bean</invoker-proxy-binding-name>
                </invoker>
             </invoker-bindings>
             <resource-adapter-name>swiftmq.rar</resource-adapter-name>
          </message-driven>
       </enterprise-beans>
    </jboss>
    

     

    Running the example

     

    • Make sure you have the Swift jmsxaasf swiftlet installed within SwiftMQ

    • Add swiftmq.rar to the deploy directory

    • Unzip the attached swiftmdb.zip

    • Change build.properties to point at your JBoss installation

    • Deploy the mdb by typing "ant" to run the deploy target in build.xml

    • Use the swiftmq example

      SimpleQueueSender

      to send a message to the queue

     

    You should get some output like the following on the jboss console:

    16:32:01,247 INFO  [STDOUT] [TextMessageImpl com.swiftmq.jms.TextMessageImpl@e77781
    messageIndex = 5_0
    messageId = ID:/xxx.xxx.xxx.xxx-10958671208480
    userId = anonymous
    clientId = null
    timeStamp = 1095867120848
    correlationId = null
    replyTo = null
    destination = testqueue@router1
    deliveryMode = 2
    redelivered = false
    deliveryCount = 1
    type = null
    expiration = 0
    priority = 4
    props = null
    readOnly = true
    sourceRouter = null
    destRouter = null
    destQueue = testqueue@router1 text=Here is a message]