1 2 Previous Next 16 Replies Latest reply on May 14, 2010 2:51 PM by andreas_back

    HornetQ Jboss as4 width EJB2.1

    Serigne Ibrahima Fall Newbie

      Hi,

       

      How to configure MDB (EJB 2.1) with hornet Q.

        • 1. Re: HornetQ Jboss as4 width EJB2.1
          Serigne Ibrahima Fall Newbie

          /**
          *
          * This bean provide methods to manage Oxbox.
          * @jboss.destination-jndi-name name= "queue/test"
          * @ejb.bean name = "MDBTransaction"
          *           destination-type = "javax.jms.Queue" acknowledge-mode =
          *           "Auto-acknowledge" subscription-durability = "Durable"
          * @ejb.transaction type="Required"
          */

          public class MDBTransactionBean implements MessageDrivenBean,
                  MessageListener
          {

              private Logger log = Logger.getLogger(this.getClass());

              protected MessageDrivenContext ctx = null;


              /**
               * Create method, called when home.create method is called.
               *
               * @ejb.create-method
               */

              public void ejbCreate() {
                     if (log.isDebugEnabled()) {
                         log.debug("ejbCreate");
                     }
              }

                  @Override
              public void onMessage(Message mess) {
                     //TODO Auto-generated method stub
                     log.info("Enter MDBProcess Oxbox. ");
                      
                     Long transactionId=null;
                      TextMessage textMessage = (TextMessage)mess;

                      String text="vide";
                      try {
                          text = textMessage.getText();
                      } catch (JMSException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }

                      log.info("message " + text);

              }

              /**
               * Remove method, called when session.remove method is called.
               *
               * @throws EJBException
               */

           

              public void ejbRemove() throws EJBException {
                  if (log.isDebugEnabled()) {
                      log.debug("ejbRemove");
                  }
              }

           

              /**
               * Internal method called on status transition.
               *
               * @throws EJBException
               */
              public void ejbActivate() throws EJBException {
                  if (log.isDebugEnabled()) {
                      log.debug("ejbActivate");
                  }
              }

           

              /**
               * Internal method called on status transition.
               *
               * @throws EJBException
               */
              public void ejbPassivate() throws EJBException {
                  if (log.isDebugEnabled()) {
                      log.debug("ejbPassivate");
                  }
              }

           

              /*
               * (non-Javadoc)
               *
               * @see javax.ejb.MessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext)
               */

           

              public void setMessageDrivenContext(MessageDrivenContext ctx) {
                  this.ctx = ctx;
              }


          }

          • 2. Re: HornetQ Jboss as4 width EJB2.1
            Serigne Ibrahima Fall Newbie

            the declaration of my queue   in hornetq-jms.xml

             

            <queue name="test">
                  <entry name="/queue/test"/>
               </queue>

             

            When I send a message in this queue my MDB doesn't consume it.

             

            I need some help  please

            • 3. Re: HornetQ Jboss as4 width EJB2.1
              Clebert Suconic Master

              You need to set the resource adapter name on the proxy config. (standard-jboss.xml), or in your jboss.xml.

              • 4. Re: HornetQ Jboss as4 width EJB2.1
                Serigne Ibrahima Fall Newbie

                I have done it but nothing, here is the config in my jboss.xml

                 

                      <message-driven>
                         <ejb-name>MDBTransaction</ejb-name>                      
                         <destination-jndi-name>/queue/test</destination-jndi-name>
                         <resource-adapter-name>jms-ra.rar</resource-adapter-name>
                      </message-driven>

                 

                In file join, the print screen of my error when I start jboss

                • 5. Re: HornetQ Jboss as4 width EJB2.1
                  Serigne Ibrahima Fall Newbie

                  Please Mister, say me exactly what I must do in jboss.xml or standardjboss.xml. I don't understand well the configuration of MDB in jboss.

                   

                  Thank's

                  • 6. Re: HornetQ Jboss as4 width EJB2.1
                    Clebert Suconic Master

                    Please read this chapter:

                     

                    http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/appserver-integration.html

                     

                     

                    The resource adapter's name for Hornetq is hornetq-ra.rar.

                     

                    All the activation properties for EJB3 would be the same for EJB2.1

                    • 7. Re: HornetQ Jboss as4 width EJB2.1
                      Serigne Ibrahima Fall Newbie
                      When I have installed hornetQ,  I have got jms-ra.rar directory in deploy directory not hornetq-ra.rar. In hornetq.sar/jms-ds.xml too, i have default this : <connection-factories>
                        <!--
                          JMS Stuff
                        -->
                        <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="hornetq:service=JMSProviderLoader,name=JMSProvider">
                            <attribute name="ProviderName">DefaultJMSProvider</attribute>
                            <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
                            <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
                            <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
                            <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
                        </mbean>
                        <!--
                          JMS XA Resource adapter, use this to get transacted JMS in beans
                        -->
                        <tx-connection-factory>
                            <jndi-name>JmsXA</jndi-name>
                            <xa-transaction/>
                            <rar-name>jms-ra.rar</rar-name>
                            <connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
                            <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</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>
                      </connection-factories>
                      • 8. Re: HornetQ Jboss as4 width EJB2.1
                        Serigne Ibrahima Fall Newbie
                        Clebert, For more info, I work with jboss4.2.0.GA
                        • 9. Re: HornetQ Jboss as4 width EJB2.1
                          Clebert Suconic Master

                          I'm not sure what you're doing wrong. Are you sure you're looking at the right directory (default-with-hornetq).

                           

                           

                          You should use the install script for as4

                           

                          export JBOSS_HOME=/path/to/your/AS4.2

                          cd hornetq-2.0.0.GA/config/jboss-as

                          ./build.sh as4

                           

                           

                          and you will see the resource adapter under deploy.

                          • 10. Re: HornetQ Jboss as4 width EJB2.1
                            Serigne Ibrahima Fall Newbie

                            I explain all step, I have done.

                             

                            Note : I work under windows XP.

                             

                            1) set JBOSS_HOME = /path/to/my/AS4.2

                             

                            2) cd hornetq-2.0.0.GA/config/jboss-as

                             

                            3)  build.bat as4

                             

                            After these, I have got two new configuration default-with-hornetq and all-with-hornetq

                             

                            For my example, I work with default-with-hornetq and in (default-with-hornetq/deploy/) directory I have two news directories (jms-ra.rar and hornetq.sar) after installing hornetQ

                             

                            4) cd  JBOSS_HOME/server/default-with-hornetq/deploy/hornetq.sar/

                             

                            5) edit hornetq-jms to add my queue  

                             

                               <queue name="test">
                                  <entry name="/queue/test"/>
                               </queue>

                             

                            6) After these, I have deployed my MDB

                             

                            Note : In file joined, you can see the directories jms-ra.rar and hornetq.sar of default-with-hornetq configuration.

                            • 11. Re: HornetQ Jboss as4 width EJB2.1
                              Serigne Ibrahima Fall Newbie

                              In standard-jboss.xml, I have uncomment this part :

                               

                              <!--Uncomment to use JMS message inflow from jmsra.rar -->

                               

                              <invoker-proxy-binding>
                                    <name>message-driven-bean</name>
                                    <invoker-mbean>default</invoker-mbean>
                                    <proxy-factory>org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory</proxy-factory>
                                    <proxy-factory-config>
                                      <activation-config>
                                         <activation-config-property>
                                            <activation-config-property-name>providerAdapterJNDI</activation-config-property-name>
                                            <activation-config-property-value>DefaultJMSProvider</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>minSession</activation-config-property-name>
                                            <activation-config-property-value>1</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>maxSession</activation-config-property-name>
                                            <activation-config-property-value>1</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>keepAlive</activation-config-property-name>
                                            <activation-config-property-value>60000</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-property>
                                            <activation-config-property-name>reconnectInterval</activation-config-property-name>
                                            <activation-config-property-value>10</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>useDLQ</activation-config-property-name>
                                            <activation-config-property-value>true</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>DLQHandler</activation-config-property-name>
                                            <activation-config-property-value>org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>DLQJNDIName</activation-config-property-name>
                                            <activation-config-property-value>queue/DLQ</activation-config-property-value>
                                         </activation-config-property>
                                         <activation-config-property>
                                            <activation-config-property-name>DLQMaxResent</activation-config-property-name>
                                            <activation-config-property-value>10</activation-config-property-value>
                                         </activation-config-property>
                                      </activation-config>
                                      <endpoint-interceptors>
                                        <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
                                        <interceptor>org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor</interceptor>
                                        <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
                                        <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
                                      </endpoint-interceptors>
                                    </proxy-factory-config>
                                  </invoker-proxy-binding>

                               

                              and I have comment this default part :

                               

                                  <!--

                                  <invoker-proxy-binding>
                                    <name>message-driven-bean</name>
                                    <invoker-mbean>default</invoker-mbean>
                                    <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
                                    <proxy-factory-config>
                                      <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
                                      <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
                                      <CreateJBossMQDestination>true</CreateJBossMQDestination>

                               

                                      <MinimumSize>1</MinimumSize>
                                      <MaximumSize>15</MaximumSize>
                                      <KeepAliveMillis>30000</KeepAliveMillis>
                                      <MaxMessages>1</MaxMessages>
                                      <MDBConfig>
                                        <ReconnectIntervalSec>10</ReconnectIntervalSec>
                                        <DLQConfig>
                                          <DestinationQueue>queue/DLQ</DestinationQueue>
                                          <MaxTimesRedelivered>10</MaxTimesRedelivered>
                                          <TimeToLive>0</TimeToLive>
                                        </DLQConfig>
                                      </MDBConfig>
                                    </proxy-factory-config>
                                  </invoker-proxy-binding>

                               

                                  --> 

                               

                              Now I have this error when I start jboss althought I have defined the destination and destinationType in my MDB

                               

                              ejb-jar.xml :

                               

                                   <!-- Message Driven Beans -->
                                    <message-driven >
                                       <description><![CDATA[This bean provide methods to manage Oxbox.]]></description>

                               

                                       <ejb-name>MDBTransaction</ejb-name>

                               

                                       <ejb-class>sn.csi.oxbox.be.mdb.MDBTransactionBean</ejb-class>

                               

                                       <messaging-type>javax.jms.MessageListener</messaging-type>
                                       <transaction-type>Container</transaction-type>
                                       <message-destination-type>javax.jms.Queue</message-destination-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>acknowledgeMode</activation-config-property-name>
                                           <activation-config-property-value>Auto-acknowledge</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>

                               

                                    </message-driven>

                               

                               

                               

                              jboss.xml :

                               

                                   <message-driven>
                                       <ejb-name>MDBTransaction</ejb-name>                      
                                       <destination-jndi-name>/queue/test</destination-jndi-name>
                                       <resource-adapter-name>jms-ra.rar</resource-adapter-name>
                                    </message-driven>

                              • 13. Re: HornetQ Jboss as4 width EJB2.1
                                Clebert Suconic Master

                                I just tried with jboss-4.2.3 and it worked. I could see the hornetq-ra on the /deploy directory

                                 

                                 

                                Also, look at this thread. The user is using a .xml to deploy properties what should be pretty much the same for you.

                                 

                                http://community.jboss.org/thread/149246?tstart=0

                                 

                                 

                                also: please understand that we offer support for free on a first come first serve basis.

                                 

                                 

                                BTW: Why don't you just change your MDB to EJB 3.0?

                                • 14. Re: HornetQ Jboss as4 width EJB2.1
                                  Serigne Ibrahima Fall Newbie

                                  Hi Clebert,

                                   

                                  I have deployed hornetQ in jboss4.2.3GA but I have an error when I start the server

                                   

                                  thank's !

                                  1 2 Previous Next