2

I am trying to setup an embedded activeMQ with Jboss 7.3.0 and activemq-rar-5.6.0. The embedded broker should be accessible from inside Jboss and also from outside(via tcp from another application)

I am facing the following exception when i start jboss with 'standalone.bat -c standalone-full.xml'

**Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.ra.activemq-ra is already registered**

I really appreciate any guidance on why i am getting this exception. I have attached below an image from the log.

Below are my configurations.

I added a resource adapter inside resource-adapters subsystem in standalone-full.xml file

  <subsystem xmlns="urn:jboss:domain:resource-adapters:5.0">
            <resource-adapters>
                <resource-adapter id="activemq-ra.rar">
                    <archive>
                        activemq-ra.rar
                    </archive>
                    <transaction-support>XATransaction</transaction-support>
                   <!-- <config-property name="ServerUrl">tcp://localhost:61616</config-property> -->
                    <config-property name="ServerUrl">vm://localhost</config-property> 
                    <connection-definitions>
                        <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/activemq/ConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQConnectionFactoryPool" use-ccm="true">
                            <xa-pool>
                                <min-pool-size>1</min-pool-size>
                                <max-pool-size>20</max-pool-size>
                            </xa-pool>
                        </connection-definition>
                    </connection-definitions>
                    <admin-objects>
                        <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/HELLOWORLDMDBQueue" use-java-context="true" pool-name="HELLOWORLDMDBQueue">
                            <config-property name="PhysicalName">HELLOWORLDMDBQueue</config-property>
                        </admin-object>
                        <admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:/topic/HELLOWORLDMDBTopic" use-java-context="true" pool-name="HELLOWORLDMDBTopic">
                            <config-property name="PhysicalName">HELLOWORLDMDBTopic</config-property>
                        </admin-object>
                    </admin-objects>
                </resource-adapter>
            </resource-adapters>
        </subsystem>

I updated the resource-adapter-ref inside the mdb tag in standalone-full.xml file.

 <subsystem xmlns="urn:jboss:domain:ejb3:6.0">
            <session-bean>
                <stateless>
                    <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
                </stateless>
                <stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
                <singleton default-access-timeout="5000"/>
            </session-bean>
            <mdb>
                <!--<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/> -->
                <resource-adapter-ref resource-adapter-name="activemq-ra.rar"/>
                <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
            </mdb>

The messaging subsystem inside standalone-full.xml is

 <subsystem xmlns="urn:jboss:domain:messaging-activemq:8.0">
            <server name="default">
                <statistics enabled="${wildfly.messaging-activemq.statistics-enabled:${wildfly.statistics-enabled:false}}"/>
                <security-setting name="#">
                    <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
                </security-setting>
                <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
                <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
                <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
                    <param name="batch-delay" value="50"/>
                </http-connector>
                <in-vm-connector name="in-vm" server-id="0">
                    <param name="buffer-pooling" value="false"/>
                </in-vm-connector>
                <http-acceptor name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param name="batch-delay" value="50"/>
                    <param name="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0">
                    <param name="buffer-pooling" value="false"/>
                </in-vm-acceptor>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
                <jms-queue name="myTestQ" entries="java:jboss/exported/jms/queue/myTestQ"/>
                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
                <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
            </server>
        </subsystem>

I Updated ra.xml file, changed the ServerUrl to tcp://localhost:61616

<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>

And set the config-property-value of the config-property BrokerXmlConfig in META-INF/ra.xml to xbean:broker-config.xml

<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>
            
             <description>To use the broker-config.xml from the root for the RAR </description>
               <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>

I created a new activemq-ra.rar file and placed it in jboss-eap-7.3\standalone\deployments folder.

enter image description here

Ben
  • 137
  • 3
  • 12
  • (1) Do you have the `messaging` subsystem defined in your `standalone-full.xml`? If so, could you share it? (2) What happens if you use a different name for your rar (e.g. `activemq5-ra.rar`) instead of `activemq-ra.rar`? (3) Why are you not using the embedded ActiveMQ Artemis instance? – Justin Bertram Nov 18 '20 at 02:57
  • @JustinBertram 1. Yes the messaging subsystem is there. I have included it in the question above 2. I tried with activemq-ra.rar only. Will try with activemq5-ra.rar 3. How do i use the embedded ActiveMQ Artemis instance ?, is it by defining the queues inside the messaging subsystem inside standalone-full.xml ? If that is the case, i don't need the activemq-ra.rar and the resource-adapter config i added in standalone-full.xml ? – Ben Nov 18 '20 at 03:47
  • Given that you have a `messaging` subsystem configured (which enables an embedded instance of ActiveMQ Artemis, including an embedded instance of its JCA RA) that's likely colliding with the `activemq-ra.rar` you're trying to configure in the `resource-adapters` subsystem. Whether or not you need all this really depends on what you're trying to do. Are you just trying to configure a JMS broker embedded into JBoss EAP so you can send and consume messages to/from it? If so you should just use the embedded instance of ActiveMQ Artemis. – Justin Bertram Nov 18 '20 at 04:02
  • Thanks Justin for the Reply. Yes I am trying to configure a JMS broker and send messages and read them asynchronously. For using the embedded ActiveMQ Artemis instance, I defined the following queue in the messaging subsystem as `` . Will the testQ be accessible from within and outside jboss using the name 'jms/queue/testQ' ? – Ben Nov 19 '20 at 22:18
  • It would probably be best for you to clarify (i.e. completely rewrite) your original question rather than asking new questions in the comment section. – Justin Bertram Nov 19 '20 at 23:25
  • Using a different name for the rar resolved the exception. I faced a different problem and posted a new question [https://stackoverflow.com/questions/64960547/jboss-7-embedded-activemq-mdb-message-listener-not-working] – Ben Nov 22 '20 at 23:04
  • OK. I added this as an answer along with another possibility. – Justin Bertram Nov 23 '20 at 00:49

1 Answers1

1

Try using a different name for your resource adapter archive. For example, use activemq5-ra.rar instead of activemq-ra.rar. I believe you're conflicting with the embedded JCA RA used for ActiveMQ Artemis integration.

Alternatively you could remove the messaging subsystem from your server's XML configuration.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • Thank You Justin, using a name different from `activemq-ra.rar` for the resource adapter solved the exception. – Ben Nov 23 '20 at 02:10