1 2 3 Previous Next 43 Replies Latest reply on Sep 19, 2012 10:05 AM by jbertram Go to original post
      • 15. Re: jboss 7 ActiveMQ integration
        jbertram

        I would recommend https://community.jboss.org/thread/201315.  The ironjacamar.xml referenced by https://blog.coffeebeans.at/?p=230 shouldn't be necessary.

         

        https://community.jboss.org/message/742224#742224 might be helpful as well.

        • 16. Re: jboss 7 ActiveMQ integration
          ioneyes

          Thanks Justin

           

          When you say ironjacamar is not necessary, does that apply to an embedded apache MQ broker ?

          The RA.xml file I have here in its notes mentions that you need to specify a broker config. I have enclosed it here for you to see.

           

           

          <?xml version="1.0" encoding="UTF-8"?>

           

          <connector 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/connector_1_5.xsd"

              version="1.5">

              <description>ActiveMQ  inbound and outbound JMS ResourceAdapter</description>

              <display-name>ActiveMQ JMS Resource Adapter</display-name>

              <vendor-name>activemq.org</vendor-name>

              <eis-type>JMS 1.1</eis-type>

              <resourceadapter-version>1.0</resourceadapter-version>

              <resourceadapter>

                  <resourceadapter-class>org.apache.activemq.ra.ActiveMQResourceAdapter</resourceadapter-class>

                  <config-property>

                      <description>

                        The URL to the ActiveMQ server that you want this connection to connect to.  If using

                        an embedded broker, this value should be 'vm://localhost'.

                      </description>

                      <config-property-name>ServerUrl</config-property-name>

                      <config-property-type>java.lang.String</config-property-type>

                      <!-- <config-property-value>tcp://localhost:61616</config-property-value>  -->

                      <config-property-value>vm://localhost</config-property-value>

                  </config-property>

                  <config-property>

                      <description>The default user name that will be used to establish connections to the ActiveMQ server.</description>

                      <config-property-name>UserName</config-property-name>

                      <config-property-type>java.lang.String</config-property-type>

                      <config-property-value>admin</config-property-value>

                  </config-property>

                  <config-property>

                      <description>The default password that will be used to log the default user into the ActiveMQ server.</description>

                      <config-property-name>Password</config-property-name>

                      <config-property-type>java.lang.String</config-property-type>

                      <config-property-value>password</config-property-value>

                  </config-property>

                  <config-property>

                      <description>The client id that will be set on the connection that is established to the ActiveMQ server.</description>

                      <config-property-name>Clientid</config-property-name>

                      <config-property-type>java.lang.String</config-property-type>

                  </config-property>

                  <config-property>

                      <description>Boolean to configure if outbound connections should reuse the inbound connection's session for sending messages.</description>

                      <config-property-name>UseInboundSession</config-property-name>

                      <config-property-type>java.lang.Boolean</config-property-type>

                      <config-property-value>false</config-property-value>

                  </config-property>

           

                        <!-- NOTE disable the following property if you do not wish to deploy an embedded broker -->

                  <config-property>

                      <description>

                        Sets the XML configuration file used to configure the embedded ActiveMQ broker via

                        Spring if using embedded mode.

           

                        BrokerXmlConfig is the filename which is assumed to be on the classpath unless

                        a URL is specified. So a value of foo/bar.xml would be assumed to be on the

                        classpath whereas file:dir/file.xml would use the file system.

                        Any valid URL string is supported.

                      </description>

                      <config-property-name>BrokerXmlConfig</config-property-name>

                      <config-property-type>java.lang.String</config-property-type>

                      <!-- <config-property-value></config-property-value>  -->

          <!--

                      <config-property-value>xbean:ironjacamar.xml</config-property-value>

          -->

                      <config-property-value>xbean:broker-config.xml</config-property-value>

           

                      <!--

                       To use the broker-config.xml from the root for the RAR

                         <config-property-value>xbean:broker-config.xml</config-property-value>

                       To use an external file or url location

                         <config-property-value>xbean:file:///amq/config/jee/broker-config.xml</config-property-value>

                      -->

                  </config-property>

           

                  <outbound-resourceadapter>

                      <connection-definition>

                          <managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>

                          <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>

                          <connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>

                          <connection-interface>javax.jms.Connection</connection-interface>

                          <connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>

                      </connection-definition>

                      <connection-definition>

                          <managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>

                          <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>

                          <connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>

                          <connection-interface>javax.jms.QueueConnection</connection-interface>

                          <connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>

                      </connection-definition>

                      <connection-definition>

                          <managedconnectionfactory-class>org.apache.activemq.ra.ActiveMQManagedConnectionFactory</managedconnectionfactory-class>

                          <connectionfactory-interface>javax.jms.TopicConnectionFactory</connectionfactory-interface>

                          <connectionfactory-impl-class>org.apache.activemq.ra.ActiveMQConnectionFactory</connectionfactory-impl-class>

                          <connection-interface>javax.jms.TopicConnection</connection-interface>

                          <connection-impl-class>org.apache.activemq.ra.ManagedConnectionProxy</connection-impl-class>

                      </connection-definition>

                      <transaction-support>XATransaction</transaction-support>

                      <authentication-mechanism>

                          <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>

                          <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>

                      </authentication-mechanism>

                      <reauthentication-support>false</reauthentication-support>

                  </outbound-resourceadapter>

                  <inbound-resourceadapter>

                      <messageadapter>

                          <messagelistener>

                              <messagelistener-type>javax.jms.MessageListener</messagelistener-type>

                              <activationspec>

                                  <activationspec-class>org.apache.activemq.ra.ActiveMQActivationSpec</activationspec-class>

           

                                  <required-config-property>

                                      <config-property-name>destination</config-property-name>

                                  </required-config-property>

                                  <required-config-property>

                                      <config-property-name>destinationType</config-property-name>

                                  </required-config-property>

           

                              </activationspec>

                          </messagelistener>

                      </messageadapter>

                  </inbound-resourceadapter>

                  <adminobject>

                      <adminobject-interface>javax.jms.Queue</adminobject-interface>

                      <adminobject-class>org.apache.activemq.command.ActiveMQQueue</adminobject-class>

                      <config-property>

                          <config-property-name>PhysicalName</config-property-name>

                          <config-property-type>java.lang.String</config-property-type>

                      </config-property>

                  </adminobject>

                  <adminobject>

                      <adminobject-interface>javax.jms.Topic</adminobject-interface>

                      <adminobject-class>org.apache.activemq.command.ActiveMQTopic</adminobject-class>

                      <config-property>

                          <config-property-name>PhysicalName</config-property-name>

                          <config-property-type>java.lang.String</config-property-type>

                      </config-property>

                  </adminobject>

              </resourceadapter>

          </connector>

           

          At present when JBoss starts up i see a complaint that there is no inbound or outbound resource adaptor. Which is in the XML. I have made a mistake somewhere I guess.

           

          Here is the error:

           

          Caused by: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain ei

          ther an outbound or inbound configuration

              at org.jboss.jca.common.metadata.ra.common.ResourceAdapter1516Impl.validate(ResourceAdapter1516Impl.java:333)

              at org.jboss.jca.common.metadata.ra.common.ConnectorAbstractmpl.validate(ConnectorAbstractmpl.java:305)

              at org.jboss.as.connector.deployers.ra.processors.ParsedRaDeploymentProcessor.deploy(ParsedRaDeploymentProcessor.java:1

          29)

          • 17. Re: jboss 7 ActiveMQ integration
            ioneyes

            Packaging of the ActiveMQ Rar was the cause of the first problem, leading to ra.xml not being processed. Now that it is we have reached a duplicate resource issue.

            I can provide configuration details if anyone can help.

             

            Here is the error:


             

            15:02:42,275 ERROR [org.jboss.msc.service] (MSC service thread 1-7) MSC000002: Invocation of listener "org.jboss.as.conn

            ector.deployers.ra.processors.ParsedRaDeploymentProcessor$1@ea9cf1" failed: java.lang.IllegalStateException: JBAS014666:

            Duplicate resource resource-adapters

                at org.jboss.as.controller.registry.AbstractModelResource$DefaultResourceProvider.register(AbstractModelResource.java:2

            25) [jboss-as-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                at org.jboss.as.controller.registry.AbstractModelResource.registerChild(AbstractModelResource.java:135) [jboss-as-contr

            oller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                at org.jboss.as.connector.deployers.ra.processors.AbstractResourceAdapterDeploymentServiceListener.transition(AbstractR

            esourceAdapterDeploymentServiceListener.java:109) [jboss-as-connector-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416) [jboss-msc-1.0.2.GA-redh

            at-1.jar:1.0.2.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49) [jboss-msc-1.0.2.GA-redhat-1.

            jar:1.0.2.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954) [jboss-msc-1.0.2.GA-re

            dhat-1.jar:1.0.2.GA-redhat-1]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_26]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_26]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

             

            We have a single inbound and outbound resource adaptor specified.

            • 18. Re: jboss 7 ActiveMQ integration
              jesper.pedersen

              Use latest AS7 nightly snapshot and ActiveMQ 5.6+

              • 19. Re: jboss 7 ActiveMQ integration
                jbertram

                If you are having issues with your ActiveMQ integration please open a new thread instead of co-opting this one.

                • 20. Re: jboss 7 ActiveMQ integration
                  ioneyes

                  Sorry... Justin.

                  Will do.

                   

                  The error has moved on now and we are just trying to wire up a connection factory. If we get no where I will open a new thread.

                   

                  Apologies again.

                  • 21. Re: jboss 7 ActiveMQ integration
                    ioneyes

                    Thanks for the help. We seem to have integrated Active MQ into JBoss 7.

                    Using the inVM broker, with in-container connection factory.

                     

                    At least we seem to be able to post JMS messages.

                     

                    Thanks again.

                    • 22. Re: jboss 7 ActiveMQ integration

                      Hi Cav,

                       

                      could you describe your set-up procedure: exact JBoss Version and what you did to get activemq working (standalone.xml , ra.xml and other relevant things you touched)?

                       

                      Thanks,

                      Richard

                      • 23. Re: jboss 7 ActiveMQ integration
                        ioneyes

                        Hi Richard,

                         

                        I promised not to hijack the thread. I hope I am adhering to forum etiquette.

                        These instructions are based on what I have done this far. I need to register an MDB and take my posted message of the queue next.

                         

                        To integrate Active MQ with JBoss I used Active MQ 5.6 or 5.7.

                         

                        Note: 5.7 is not a full download. You have grab the 5.7 delta and apply it to the 5.6 download (at the current time of writing). To save you the pain of this step, use 5.6.

                        https://activemq.apache.org/activemq-560-release.html

                         

                        Note: JBoss versions that are compatible with the help below can be JBoss: 7.2.0.Alpha1-SNAPSHOT or 6.00-EAP.

                        https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/

                         

                        The Active MQ RAR deployable artifact should not be modified. So ra.xml stays the same as supplied by the download.

                        Place it in <JBoss install dir>\standalone\deployments. Add a doDeploy file to get JBoss to deploy it.

                         

                        Now I integrate Active MQ (5.6 or 5.7) with JBoss (6 or 7.2-alpha)

                         

                        Here is the configuration for a connection factory, one queue and one topic, within standalone.xml.

                                <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">

                                    <resource-adapters>

                                        <resource-adapter>

                                            <archive>

                                                activemq-rar-5.7-SNAPSHOT.rar

                                            </archive>

                                            <transaction-support>XATransaction</transaction-support>

                                            <config-property name="UseInboundSession">false</config-property>

                                            <config-property name="Clientid">undefined</config-property>

                                            <config-property name="UserName">### admin username ###</config-property>

                                            <config-property name="Password">### admin password ###</config-property>

                                            <config-property name="ServerUrl">vm://localhost</config-property>

                                            <connection-definitions>

                                                <connection-definition

                                                    class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory"

                                                    jndi-name="java:jboss/exported/ConnectionFactory" enabled="true"

                                                    use-java-context="true" pool-name="ConnectionFactory" />

                                            </connection-definitions>

                                            <admin-objects>

                                                <admin-object class-name="org.apache.activemq.command.ActiveMQQueue"

                                                    jndi-name="java:jboss/queue/fromSomeWhereQueue" use-java-context="true"

                                                    pool-name="fromSomeWhereQueue">

                                                    <config-property name="PhysicalName">fromSomeWhereQueue</config-property>

                                                </admin-object>

                                                <admin-object class-name="org.apache.activemq.command.ActiveMQTopic"

                                                    jndi-name="java:jboss/fromSomewhereTopic" use-java-context="true"

                                                    pool-name="fromSomewhereTopic">

                                                    <config-property name="PhysicalName">fromSomewhereTopic</config-property>

                                                </admin-object>

                                            </admin-objects>

                                        </resource-adapter>

                                    </resource-adapters>

                                </subsystem>

                        I have kept queue, topic and their associated pool names the same for ease of reading.

                         

                        Now I need to place a message on the queue.

                        I wrote the following code.

                         

                        String queueConnectionFactoryJNDI = "java:jboss/exported/ConnectionFactory";

                         

                        oConnectionFactory = (QueueConnectionFactory)oInitialContext.lookup(queueConnectionFactoryJNDI);

                        Connection oConnection = oConnectionFactory.createConnection();

                        Session oSession = oConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                        Destination oDestination = (Queue) oInitialContext.lookup("java:jboss/queue/fromSomeWhereQueue");

                        MessageProducer oMessageProducer = oSession.createProducer((Queue)oDestination);

                        TextMessage oTextMessage = oSession.createTextMessage();

                        oTextMessage.setText("Hello Apache MQ Guru's");

                        oMessageProducer.send(oTextMessage);

                         

                        When configured correctly, you should see JCA messages in the server console akin to this:

                        12:33:45,420 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-8) JBAS010406: Registered connection factor

                        y java:jboss/exported/ConnectionFactory

                         

                        12:33:45,423 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-8) JBAS010405: Registered admin object at java:jboss/queue/fromSomeWhereQueue

                         

                        I would like to register an MDB to listen on a queue next, when I pay a visit to messaging again.

                         

                        Special thanks to JBoss support for your help in moving this forward.

                        • 24. Re: jboss 7 ActiveMQ integration
                          ioneyes

                          Just one more note.

                           

                          I am running all this within an Eclipse project. This automatically handles deployment for me.

                          Forgive me if I have missed anything out that is required when completing this outside of a dev env.

                           

                          If you want to access the Queue and post messages from outside the container, you can facade the JMS queue with a Stateless Session Bean.

                          This should adhere to any security and/or transactionality that may be in place.

                           

                          Fingers crossed JBoss may allow access direct at some stage soon.

                           

                          This means the code in the example was placed in a WAR file deployed to the server.

                          • 25. Re: jboss 7 ActiveMQ integration
                            ioneyes

                            Hi All,

                             

                            I now have an MDB registered. So I can now post a message on the queue and fire the downstream MDB.

                            There is a small change to the above standalone for this to work end-to-end and that is to remove the clientID reference in the resource adapter spec.

                             

                            So it becomes:

                             

                             

                             

                                    <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">

                                        <resource-adapters>

                                            <resource-adapter>

                                                <archive>

                                                    activemq-rar-5.7-SNAPSHOT.rar

                                                </archive>

                                                <transaction-support>XATransaction</transaction-support>

                                                <config-property name="UseInboundSession">false</config-property>

                                               <config-property name="Clientid">undefined</config-property>

                                                <config-property name="UserName">### admin username ###</config-property>

                                                <config-property name="Password">### admin password ###</config-property>

                                                <config-property name="ServerUrl">vm://localhost</config-property>

                                                <connection-definitions>

                                                    <connection-definition

                                                        class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory"

                                                        jndi-name="java:jboss/exported/ConnectionFactory" enabled="true"

                                                        use-java-context="true" pool-name="ConnectionFactory" />

                                                </connection-definitions>

                                                <admin-objects>

                                                    <admin-object class-name="org.apache.activemq.command.ActiveMQQueue"

                                                        jndi-name="java:jboss/queue/fromSomeWhereQueue" use-java-context="true"

                                                        pool-name="fromSomeWhereQueue">

                                                        <config-property name="PhysicalName">fromSomeWhereQueue</config-property>

                                                    </admin-object>

                                                    <admin-object class-name="org.apache.activemq.command.ActiveMQTopic"

                                                        jndi-name="java:jboss/fromSomewhereTopic" use-java-context="true"

                                                        pool-name="fromSomewhereTopic">

                                                        <config-property name="PhysicalName">fromSomewhereTopic</config-property>

                                                    </admin-object>

                                                </admin-objects>

                                            </resource-adapter>

                                        </resource-adapters>

                                    </subsystem>

                             

                             

                            With corresponding output as follows:

                             

                            16:27:36,655 INFO  [stdout] (default-threads - 3) ActiveMQTextMessage {commandId = 13, responseRequired = true, messageId = ID:SWEETCORN-52564-1343230036458-5:1:2:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:SWEETCORN-52564-1343230036458-5:1:2:1, destination = queue://FromETSQueue, transactionId = null, expiration = 0, timestamp = 1343230056646, arrival = 0, brokerInTime = 1343230056649, brokerOutTime = 1343230056651, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@163a3c40, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 1052, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = Hello Apache MQ Guru's}

                            • 26. Re: jboss 7 ActiveMQ integration
                              ioneyes

                              Once again - thanks to JBoss support for their help in moving this forward.

                              • 27. Re: jboss 7 ActiveMQ integration
                                ioneyes

                                To instruct JBoss to treat all your MDB's as ActiveMQ MDB's you need to add the following...


                                <subsystem xmlns="urn:jboss:domain:ejb3:1.3">



                                ...

                                <mdb>

                                <resource-adapter-ref resource-adapter-name="activemq-rar-5.7-SNAPSHOT.rar"/>

                                <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>

                                </mdb>

                                </subsystem>

                                This sets the default messaging provider.

                                 

                                If you elect to run multiple messaging providers and Active MQ is not your default, you will need to specify the resource adapter that each (active MQ) MDB is to use, by annotating the MDB. As shown below...

                                 

                                @MessageDriven(

                                        activationConfig = {

                                                @ActivationConfigProperty(propertyName="destinationType",     propertyValue="javax.jms.Queue"),

                                                @ActivationConfigProperty(propertyName="destination",         propertyValue="fromSomewhereQueue"),

                                                @ActivationConfigProperty(propertyName="acknowledgeMode",   propertyValue="Auto-acknowledge"),

                                        })

                                @ResourceAdapter("activemq-rar-5.7-SNAPSHOT.rar")

                                If you do not annotate the MDB, then the default provider will be used.

                                 

                                NOTE: The destination within the @MessageDriven annotation must be the physical name taken from standalone.xml and not the JNDI name as it is in Hornet Queue configuration.

                                • 28. Re: jboss 7 ActiveMQ integration
                                  ioneyes

                                  To help that little bit more I have created a document that brings all these posts together and can be used as a reference for your own JBoss to Active MQ integration efforts.

                                   

                                  JBoss 2 Active MQ pdf

                                   

                                  Hope it helps.

                                  • 29. Re: jboss 7 ActiveMQ integration
                                    ioneyes

                                    I have been working on DB Persistence for Active MQ.

                                    This is a little involved and requires editing and manipulation of the ActiveMQ RAR file as well as its broker-config.xml and ra.xml files.

                                    The good news is that I can persist to MySQL or Oracle, changing between the 2 with a single line change.

                                     

                                    I will update the JBoss 2 ActiveMQ document mentioned above once I have documented and double-checked the solution.