I encounter some problems using remote JMS communication between 2 JBoss EAP 7.1 servers (with ActiveMQ Artemis embedded).
An EJB MDB, deployed on a second server, try to access Artemis queues deployed on a first server (same machine but different port).
The MDB client (XA use case) :
1) consumes message from a request queue exported by the first server
2) processes message content, including database updates
3) sends a response to a reply queue exposrted by same remote server
So, first server exports 3 (Artemis) queues : - TestQueueReq, for requests consumed by 2nd app server - TestQueueRep, for replies sent by 2nd app server - DLQTestQueue, for dead letter queue
Extract from first server configuration:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security enabled="false"/>
<address-setting name="jms.queue.TestQueue#" dead-letter-address="jms.queue.DLQTestQueue" expiry-address="jms.queue.ExpiryQueue" redelivery-delay="500" redelivery-multiplier="2.0" max-delivery-attempts="3" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
( …/…)
<jms-queue name="DLQTestQueue" entries="java:/jms/queue/DLQTestQueue"/>
<jms-queue name="TestQueueReq" entries="java:/jms/queue/TestQueueReq java:jboss/exported/jms/queue/TestQueueReq" durable="true"/>
<jms-queue name="TestQueueRep" entries="java:/jms/queue/TestQueueRep java:jboss/exported/jms/queue/TestQueueRep" durable="true"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
</server>
</subsystem>
Second server is configured as documented in https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/configuring_messaging/resource_adapters#use_provided_amq_adapter
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security enabled="false"/>
:…/…)
<http-connector name="remote-http-connector" socket-binding="remote-server" endpoint="http-acceptor"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
<pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-http-connector"/>
</server>
</subsystem>
External context binding is also configured on the second server according to this official doc : https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/configuring_the_naming_subsystem
Message sent to TestQueueReq is correctly consumed by MDB.
@ResourceAdapter("remote-artemis")
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "TestQueueReq")
}, messageListenerInterface = MessageListener.class)
@ApplicationScoped
public class ExampleSFBean implements ExampleSF, MessageListener {
@Override
public void onMessage(final Message message) {
…
The problem happens when we try, within the MDB, to send a message to the reply queue. I have tried many different strategies for resource injection in the MDB :
@Inject
@JMSConnectionFactory("java:/jms/remoteCF")
private JMSContext jmsContext;
@Resource (lookup = "java:global/remoteContext")
private Context remoteContext;
@Resource (lookup="java:global/TestQueueRep")
private Queue queueRep;
But we keep on getting exceptions when trying to send response, due to injection/lookup problems.
- jmsContext is null, except when MDB is @ApplicationContext annotated.
- queueRep injection does not work since the lookup fail (with : Invalid URL scheme name "null")
- Manual lookup using remoteContext fails with the, same as previous, following exception:
Caused by: java.lang.RuntimeException: javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name
"null" at org.jboss.as.naming.subsystem.NamingBindingAdd$LookupManagedReferenceFactory.getReference(NamingBindingAdd.java:451) at org.jboss.as.naming.subsystem.NamingBindingAdd$MutableManagedReferenceFactory.getReference(NamingBindingAdd.java:354) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143) ... 99 more Caused by: javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name "null" at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:808) at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:155) at javax.naming.InitialContext.lookup(InitialContext.java:421)
- Question 1 : can someone tell me what is wrong with my code/configuration and why automatic injection of remote reply queue does not work ? Or, at least, why manual lookup from the remote context is not working? And what this scheme error means…
- Question 2 : if MDB is not @ApplicationScoped annotated, JMSContext is not injected (null). Is it normal ? If yes, is there any drawback annotating the MDB that way?
Thanks