Version 11

     

    Integration with SonicMQ

     

     

     

    This wiki completes and corrects the following tutorial provided by Sonic Software

     

    http://www.sonicsoftware.com/cgi-bin/sonic.cgi/dx_results.w?search=jboss&Submit.x=0&Submit.y=0

     

     

     

     

     

    Scenario A: I want to replace JBossMQ with SonicMQ

     

     

    • jms directory

    Delete the content of the jms directory in $JBOSS_HOME/server/$SERVER_CONF/deploy

     

     

     

    • sonicmq-service.xml

    In this folder, create a file titled sonicmq-service.xml and paste the following

    <?xml version="1.0" encoding="UTF-8"?>
    <server>
        <mbean code="com.sonicsw.pso.jndiloader.jboss.JBossLoader" name="sonic.mq:service=JNDILoader">
            <attribute name="LoaderConfigURL">file://localhost/D:\jboss-4.0.1sp1\server\default\deploy\jms\jndiloader-conf.xml</attribute>
            <depends>jboss:service=Naming</depends>
        </mbean>
        
    
      <!-- The JMS provider loader -->
      <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="jboss.mq:service=JMSProviderLoader,name=SonicMQProvider">
        <attribute name="ProviderName">DefaultJMSProvider</attribute>
        <attribute name="ProviderAdapterClass">
          org.jboss.jms.jndi.JNDIProviderAdapter
        </attribute>
        <attribute name="QueueFactoryRef">java:/QueueConnectionFactory</attribute>
        <attribute name="TopicFactoryRef">java:/TopicConnectionFactory</attribute>
      </mbean>
    
      <!-- The Sonic server session pool for Message Driven Beans            -->
      <mbean code="org.jboss.jms.asf.ServerSessionPoolLoader"
          name="jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool">
        <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
        <attribute name="PoolName">StdJMSPool</attribute>
        <attribute name="PoolFactoryClass">
          org.jboss.jms.asf.StdServerSessionPoolFactory
        </attribute>
      </mbean>
        
    </server>
    

     

    Note: The Sonic JBossLoader is somewhat inflexible. You may consider creating (per queue or topic) MBean instances that bind JNDI entries. This matches the model that JBossMQ uses.

     

     

     

     

    • JMS Resource Adapter

     

    As you may have noticed, the tutorial talks only about configuring JBossAS so that mdb containers can listen to SonicMQ destinations. Using the JMS resource adapter, developers can also write jms clients (ejbs, servlets) which send messages to these very destinations.

     

    First, in sonicmq-service.xml you need to define a connection factory as follows:

    <server>
    ....
    
        <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
      <tx-connection-factory>
        <jndi-name>JmsXA</jndi-name>
        <xa-transaction></xa-transaction>
        <rar-name>jms-ra.rar</rar-name>
        <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
        <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
        <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
        <max-pool-size>20</max-pool-size>
        <security-domain-and-application>JmsXARealm</security-domain-and-application>
      </tx-connection-factory>
        
    </server>
    

     

     

    The JMS RA knows where to find the jms provider via the JmsProviderAdapterJNDI attribute.

     

    The client code would then look like this

    ...
              ic = new InitialContext();
              cf = (QueueConnectionFactory)ic.lookup("java:/JmsXA");
              c = cf.createQueueConnection();
    ...
    

     

     

     

    More information about the JMS Resource Adapter can be found in this wiki http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJMSRA

     

    • jndiloader-conf.xml

    The tutorial tells to copy this file to $JBOSS_HOME/server/$SERVER_CONF. No file should dangle at the root of the server configuration. In fact it better be in ../deploy/jms for practical reasons explained later in this document. Remember to update the attribute LoaderConfigURL in sonicmq-service.xml

     

     

     

     

    FAQ

     

    Q. When JBossAS started I get the following exception:

     

     

    550 ERROR [org.jboss.jms.jndi.JMSProviderLoader] Starting failed jboss.mq:name=JBossMQProvider,service=JMSProviderLoader
    java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.jms.jndi.JBossMQProvider
    at org.jboss.mx.loading.LoadMgr3.beginLoadTask(Lorg.jboss.mx.loading.ClassLoadingTask;
      Lorg.jboss.mx.loading.UnifiedLoaderRepository3;)Z(LoadMgr3.java:292)
    at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(Ljava.lang.String;ZI)
      Ljava.lang.Class;(RepositoryClassLoader.java:464)
    at org.jboss.mx.loading.RepositoryClassLoader.loadClass(Ljava.lang.String;Z)
      Ljava.lang.Class;(RepositoryClassLoader.java:374)
    at java.lang.ClassLoader.loadClass(Ljava.lang.String;)Ljava.lang.Class;(Unknown Source)
    at org.jboss.jms.jndi.JMSProviderLoader.startService()V(JMSProviderLoader.java:195)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart()V(ServiceMBeanSupport.java:272)
    ...
    

     

     

    The fix is to edit the sonicmq-service.xml file and update the ProviderAdapterClass attribute

     

    then restart the instance.

     

      ....
      <!-- The JMS provider loader -->
      <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="jboss.mq:service=JMSProviderLoader,name=SonicMQProvider">
        <attribute name="ProviderName">DefaultJMSProvider</attribute>
        <attribute name="ProviderAdapterClass">
          org.jboss.jms.jndi.JNDIProviderAdapter
        </attribute>
      ...
    

     

     

    Check out this wiki for more detailed information: HowDoIConfigureTheJMSResourceAdapterToUseARemoteConnectionFactory

     

    Q. When JBossAS started it gave the following exception:

     

     

     

        java.lang.AbstractMethodError: com.sonicsw.pso.jboss.v1.SonicMQServerSessionPoolFactory.getServerSessionPool
     (Ljavax/jms/Destination;Ljavax/jms/Connection;
     IIJZIZLjavax/jms/MessageListener;)Ljavax/jms/ServerSessionPool;
    

     

     

    Please review this knowledge base solution from Sonic (obsolete link)

     

    http://search.sonicsoftware.com/prokb/22405.html

     

     

    Q. I am having trouble getting XA to work:

     

     

     

    Please review this knowledge base solution from Sonic (obsolete link)

     

    http://search.sonicsoftware.com/prokb/22405.html

     

    If this is not enough, you'll have to contact Sonic to know more about their so-called " fully-supported

    SonicMQ JCA-based Resource Adapter for JBoss 4.0.2"

     

     

     

    Some notes about Sonic's tutorial

     

    The Sonic team advises to drop the jms folder altogether. We usually don't recommend it as you lose the ability to remove the jms services in one click. This option is quite useful to reduce startup time during the development phase.

     

     

     

    Resources:

     

    http://www.sonicsoftware.com/cgi-bin/sonic.cgi/dx_results.w?search=jboss&Submit.x=0&Submit.y=0

     

    http://www.jboss.org/index.html?module=bb&op=viewtopic&t=59187

     

    http://www.sonicsoftware.com/products/sonicmq/index.ssp