EAP JNDI queue names not map to admin-object in AMQ broker

Latest response

Hi,

Trying to use exerna queue manager, AMQ broker 7.2, with EAP 7.2.

My problem is that when the EAR/WAR startup it creates a dynamic queue in the AMQ with the JNDI-name both as name and address (not mapped to the physical queue name).
If I rename the queue config to the jndi-name it get mapped and use that queue...

So the mappning within the EAP to the admin-object seems to be erroneous configured...

The queues created in the broker are:

name: TestQueue address:TestQueue <- this is created by the broker (from broker.xml)
name: java:jboss/jms/queue/TestQueue address: java:jboss/jms/queue/TestQueue  <- this is created dynamically from the EAR/WAR

Tried to follow the instuctions:
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.2/html/configuring_messaging/resource_adapters#using_jboss_amq_for_remote_jms_communication


AMQ: broker.xml


  ...
  <acceptor name="artemis">tcp://0.0.0.0:61616?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,M\
QTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
  ...
  <address name="TestQueue">
    <anycast>
      <queue name="TestQueue" />
    </anycast>
  </address>

EAP: standalone-full.xml


<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
  ...
  <pooled-connection-factory name="activemq-ra-remote" entries="java:/RemoteJmsXA java:jboss/RemoteJmsXA" connectors="netty-remote-throughput" transaction="xa"/>

<subsystem xmlns="urn:jboss:domain:naming:2.0">
  ...
  <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
    <environment>
        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
        <property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/>
        <property name="queue.TestQueue" value="TestQueue"/>
  ...
  <lookup name="java:jboss/jms/queue/TestQueue" lookup="java:global/remoteContext/TestQueue"/>

<subsystem xmlns="urn:jboss:domain:resource-adapters:5.0">
  ...
  <resource-adapter id="activemq-rar.rar">
    <archive>
      activemq-rar.rar
    </archive>
    <transaction-support>XATransaction</transaction-support>
    <config-property name="ServerUrl">
      tcp://localhost:61616?jms.rmIdFromConnectionId=true
    </config-property>
  ...
  <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ConnectionFactory" enabled="true" tracking="false" pool-name="QUEUEPOOL">
  ...
  <admin-objects>
    <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue.TestQeueue" use-java-context="true" pool-name="TestQeueue">
      <config-property name="PhysicalName">
        TestQeueue
      </config-property>
    </admin-object>

RA: ra.xml


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

Best regards,
Fredrik

Responses

If I'm no mistake you are trying to use AMQ 6 RA with AMQ 7 that won't work. Why don't you try to use the AMQ 7 RA?

Hi Tom!

Oooooo.... Gaaaah! :-o Can it be?

AMQ: 2020-06-30 15:54:32,159 INFO [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.6.3.redhat-00015 [0.0.0.0, nodeID=f3274957-b7ab-11ea-abbf-005056\ 9d6ae1]

EAP: 2020-06-30 16:10:04,733 INFO [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: JBoss EAP 7.2.8.GA (WildFly Core 6.0.27.Final-redhat-00001) starting

RA: activemq-rar-5.11.0.redhat-630329.rar (I tried to check the redhat-VERSION in the lib-folder and match, but maybe wrong thinking... :-o )

Do you think I run the wrong version? :-o Downloaded version amq-broker-7.2.3-bin.zip...

Can you point out correct version for RA download?

Br, Fredrik

Changed to activemq-rar-5.15.13.rar

Still the same problem...

I'm not sure but I think the jndi-mapping between the AMQ context and the EAP context is wrong...

Should the admin-object jndi be specific to the AMQ?

<admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/TestQueue" use-java-context="true" pool-name="TestQueue">

The external-context name, should it correspond to the EAP context?

   <external-context name="java:/jboss/jms" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                    <environment>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/>
                        <property name="queue.TestQueue" value="TestQueue"/>

And the lookup be the AMQ vs EAP?

 <lookup name="java:/TestQueue" lookup="java:/jboss/jms/queue/TestQueue"/>

Sorry, lot of question... but have been strugling with this for some days now... :/

Br, Fredrik

Additional;

Due to the fact that the connection was established and queues (even wrong names/addresses) was created I thought that the RA was working... But maybe don't handle the mapping correct regarding PhysicalNames and so...

I thought that I hade some errors in my standalone-full.xml with jndi-mappings, that globalContext was quite confusing... I have change this now to:


<external-context name="java:/jboss/jms" module="org.apache.activemq.artemis" class="javax.naming.InitialContext"> <environment> <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/> <property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/> <property name="queue.TestQueue" value="TestQueue"/> </environment> </external-context> <lookup name="java:/TestQueue" lookup="java:/jboss/jms/queue/TestQueue"/> <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/CoordReceive" use-java-context="true" pool-name="TestQueue"> <config-property name="PhysicalName"> TestQueue </config-property> </admin-object>

Still the same problem...

But I will download a new RA version drirectly and try!

Yep, you are suing AMQ 6 RA. You need to use AMQ 7 RA to start with. It comes with EAP 7.2 and it's built in. You find it under pool-connection in the messaging subsystem. There is a chapter in the EAP messaging docs that describes how to setup EAP with external AMQ 7 broker [1].

Take a look at that. You may add external context for JNDI lookups.

Tom

https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3/html-single/configuring_messaging/index#jms_resources_configuration_for_a_remote_Artemis-based_broker

Okay! Great! Will look into fetch the correct RA version!

Yes, thanks, that the guide I have used.... :-o

Get back with results tomorrow...

No, I actually followed this guide: https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.2/html/configuring_messaging/resource_adapters#using_jboss_amq_for_remote_jms_communication

We want to use the AMQP protocol... but I'll try this guide...

When you mean to use the build-in RA you mean to use following and configure it according to the guide?!?

/opt/jboss/current/modules/system/layers/base/org/apache/activemq/artemis/ra/main
[jboss@dev main]$ ls -al
total 164
drwxrwxrwx. 2 jboss jboss     65 Jan  7  2019 .
drwxrwxrwx. 3 jboss jboss     18 Jan  7  2019 ..
-rwxrwxrwx. 1 jboss jboss 161314 Jan  7  2019 artemis-ra-2.6.3.redhat-00014.jar
-rwxrwxrwx. 1 jboss jboss   2064 Jan  7  2019 module.xml

Tom,

Can you please advice how I add and configure the built in AMQ 7 RA? From the manual it seems that it's already connected when using the pooled-connection-factories... but... how to handle security to AMQ broker? According to application security domain?

Should we follow chapter 31.1, 31.2 and 31.3 - and then we should be fine?

Sorry about this question... think it should be square one... 4 years since doing this, and then it was ibm... :-o

We see that the domain::resource-adapters is empty, is this correct?

The external AMQ broker uses password, where to control security (name/password), application security domain?

And do we don't need any admin-object with the builtin ra?

Sorry, many questions but not totally clear...

From the artemis.log I get following.

2020-06-30 15:54:31,478 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address TestQueue supporting [ANYCAST]
2020-06-30 15:54:31,480 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue TestQueue on address TestQueue

And when EAP-MDB-RA connects:

2020-06-30 16:03:35,391 DEBUG [org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl] ClusterCommunication::Sending notification for addBinding LocalQueueBinding [address=java:jboss/jms\
/queue/TestQueue, queue=QueueImpl[name=java:jboss/jms/queue/TestQueue, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=f3274957-b7ab-11ea-abbf-0050569d6ae1], te\
mp=false]@4e28c8ad, filter=null, name=java:jboss/jms/queue/TestQueue, clusterName=java:jboss/jms/queue/TestQueuef3274957-b7ab-11ea-abbf-0050569d6ae1] from server ActiveMQServerI\
mpl::serverUUID=f3274957-b7ab-11ea-abbf-0050569d6ae1

&Freddan

You can't use AMQP since all RAs are XA and AMQP protocol does not support XA. From EAP to AMQ 7 only supported protocol is CORE.

Tom

Yes, my bad... from EAP and the EARs/WARs we don't use AMQP...

Only from external applications, and they directly have communication with the broker...

I'll come back with results as soon as I have any...

Hi Tom,

I started all over from a clean standalone-full and created a solution from the MDB example (org.jboss.eap.quickstarts.helloworld-mdb).

When used the JMSDestinationDefinition in the HelloWorldMDBServletClient I got conflicting bindings.

WFLYEE0047: Incompatible conflicting binding at java:/queue/HELLOWORLDMDBQueue...

So I removed the JMSDestination part in the MDB and it started to work (according to https://access.redhat.com/solutions/3668421).

Also turned off the security to have one less issue to struggle with... :)

I used the resource-adapter annotation in the MDB queue class.

@ResourceAdapter("remote-artemis")
@MessageDriven(name = "HelloWorldQueueMDB", activationConfig = {
      @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jboss/jms/queue/HELLOWORLDMDBQueue"),

If I don't use the resource adapter annotation I get following resource adapter (default - which not works...).

2020-07-06 00:52:53,191 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0042: Started message driven bean 'HelloWorldQueueMDB' with 'activemq-ra.rar' resource adapter

Can we control this in the standalone-full? So we don't need the annotation within the MDB?

The standalone look like following.

<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
  <server name="default">
     <remote-connector name="netty-remote-throughput" socket-binding="messaging-remote-throughput"/>
  . . .
  <pooled-connection-factory name="remote-artemis" entries="java:/jms/RemoteJmsXA java:jboss/RemoteJmsXA" connectors="netty-remote-throughput" transaction="xa"/>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
    <bindings>
        <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
    <environment>
        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
        <property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/>
        <property name="queue.HELLOWORLDMDBQueue" value="HELLOWORLDMDBQueue"/>
      </environment>
    </external-context>
    <lookup name="java:/jboss/jms/queue/HELLOWORLDMDBQueue" lookup="java:global/remoteContext/HELLOWORLDMDBQueue"/>
    </bindings>
  <remote-naming/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ejb3:5.0">
  <mdb>
      <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
      <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
  </mdb>
<subsystem xmlns="urn:jboss:domain:ee:4.0">
 <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasourcesExampleDS" jms-connection-factory="java:/jms/RemoteJmsXA" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
<outbound-socket-binding name="messaging-remote-throughput">
  <remote-destination host="localhost" port="61616"/>
</outbound-socket-binding>

Our scenario, FUSE camel bundle send xml data over AMQP:5672 to the queue at the broker and the MDB receives it! Victory! So far so good... some details still to solve regarding lot of legacy stuff.

So, we still have two issues to solve, or understand... The Consumption of the Queue is 15 times, so its seems that it use 15 connections to the queue, looking to the console/artemis/queues, consumption count is 15. Is this normal according to the mdb-strict-max-pool? I was expecting only one consumer count... Should the session count be a number, so it can serve the incoming message on the queue?

attributes operations  50  HELLOWORLDMDBQueue  HELLOWORLDMDBQueue  ANYCAST  true  -1  false  15  0.0  0

2020-07-06 00:52:55,568 INFO  [org.apache.activemq.artemis.ra] (default-threads - 2) AMQ151001: Attempting to reconnect org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter@798f9ea7 destination=jboss/jms/queue/HELLOWORLDMDBQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)

The second one is to enable security, user and password for the broker. Should this be controlled from the application security domain? Do we need to update and re-compile all of our MDBs or can we control this within the EAP/WF/JBoss? Or just add user="****" password="****" to the pooled-connection-factory?

Additional: Can you please explain, in short, the relation between the pooled-connection factory within the ejb3 domain and the naming domain external context bindings and the default binding context within the ee domain?

Tom, must say you are always as helpful as I remembered you when I got your help for 5 years ago! ;-) Thanks!!

Best regards, Fredrik

Here's a jboss cli script that creates EAP 7.3.1 configuration in standalone mode for accessing external AMQ 7 broker.

The script creates: - system properties - outbound sockets - external JNDI context - updates ee subsystem - creates pooled connection factory (RA) to access external artemis broker.

in $JBOSS_HOME/bin create file

amq7.properties with proeprties

user={user name here} password={user password here} amq7.host={amq7 broekr host name} amq7.port=61616

(save script as file activemq-ra-7.cli)

/system-property=artemis.user:add(value=${user})
/system-property=artemis.password:add(value=${password})
/system-property=artemis.host:add(value=${amq7.host})
/system-property=artemis.port:add(value=${amq7.port})

/subsystem=ee:write-attribute(name=annotation-property-replacement,value=true)
/subsystem=ee:write-attribute(name=jboss-descriptor-property-replacement,value=true)
/subsystem=ee:write-attribute(name=spec-descriptor-property-replacement,value=true)

/subsystem="naming"/binding="java:global/remote":add(binding-type="external-context",class="javax.naming.InitialContext",environment={"java.naming.factory.initial" => "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory","java.naming.provider.url" => "tcp://${artemis.host}:${artemis.port}","connectionFactory.ConnectionFactory" => "tcp://${artemis.host}:${artemis.port}","queue.testQueue" => "testQueue","queue.inQueue" => "inQueue","queue.outQueue" => "outQueue"},module="org.apache.activemq.artemis")
/subsystem="naming"/binding="java:/jms/amq/queue/testQueue":add(binding-type="lookup",lookup="java:global/remote/testQueue")
/subsystem="naming"/binding="java:/jms/amq/queue/inQueue":add(binding-type="lookup",lookup="java:global/remote/inQueue")
/subsystem="naming"/binding="java:/jms/amq/queue/outQueue":add(binding-type="lookup",lookup="java:global/remote/outQueue")


/socket-binding-group="standard-sockets"/remote-destination-outbound-socket-binding="artemis-external-broker":add(host="${artemis.host}",port="${artemis.port}")


/subsystem="messaging-activemq"/server="default"/remote-connector="netty-remote-broker":add(socket-binding="artemis-external-broker")


/subsystem="messaging-activemq"/server="default"/pooled-connection-factory="activemq-ra-remote":add(connectors=["netty-remote-broker"],entries=["java:/RemoteJmsXA","java:jboss/RemoteJmsXA"],ha="true",max-pool-size="30",min-pool-size="15",password="${artemis.password}",statistics-enabled="true",transaction="xa",user="${artemis.user}",jndi-params="java.naming.factory.initial\=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;java.naming.provider.url\=tcp://${artemis.host}:${artemis.port};java.naming.security.principal\=${artemis.user};java.naming.security.credentials\=${artemis.password}",rebalance-connections="true",setup-attempts="-1",setup-interval="5000",use-jndi="true")

To run the script:

cd $JBOSS_HOME
cp -rp standalone standalone-amq-7
cd  $JBOSS_HOME/bin
./ standalone.sh -Djboss.server.base.dir=$JBOSS_HOME/standalone-amq-7 --server-config=standalone-full.xml  --properties=amq7.properties

jboss-cli.sh --connect --file=activemq-ra-7.cli

At this point restart your JBoss server.

My MDB looks like this

@MessageDriven(name = "RemoteQueueMDB", activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "${remote.in.queue.fqn}"),
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "${max.session}"),
    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "${use.jndi}"),
    @ActivationConfigProperty(propertyName = "hA", propertyValue = "${ha}"),
    @ActivationConfigProperty(propertyName = "rebalanceConnections", propertyValue = "${rebalance.connections}"),
    @ActivationConfigProperty(propertyName = "user", propertyValue = "${user.name}"),
    @ActivationConfigProperty(propertyName = "password", propertyValue = "${user.password}")
      },mappedName = "${remote.in.queue.fqn}")
@ResourceAdapter("activemq-ra-remote")
public class RemoteQueueMDB implements MessageListener {

and my jboss.properties

remote.in.queue.short=inQueue
remote.in.queue.fqn=java:/jms/amq/queue/inQueue
remote.out.queue.short=outQueue
remote.out.queue.long=java:/jms/amq/queue/outQueue
jca.connection.factory=java:/RemoteJmsXA
user.name=quickuser
user.password=quick123+
external.context=java:global/remote
use.jndi=true
jndi.params=java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory;java.naming.provider.url=http-remoting://${artemis.host}:${artemis.port};java.naming.security.principal=${artemis.user};java.naming.security.credentials=${artemis.password}
max.session=16
rebalance.connections=true
ha=true

It should work out of the box.

Wow, fantastic! Great Thanks! King! <3

I'm now digging into set-up JMS Bridge for this... ;-) LoL