EAP JNDI queue names not map to admin-object in AMQ broker
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?
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
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
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.