I have EJB deployed on a WildFly 18 server. I want to send message to a queue deployed on a remote WildFly 18 server (through ActiveMQ Artemis). Is that possible using injection and JCA and a poole-connection-factory?
Connection factory and queue are configured in the remote Wildfly as below:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:8.0">
...
<pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-http-connector"/>
...
</subsystem>
On the remote server, the queue is configured as below:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:8.0">
...
<jms-queue name="WildFlyCookbookQueue" entries="java:/jms/queue/test java:jboss/exported/jms/queue/test"/>
...
</subsystem>
UPDATE
Here is my EJB trying to send message to the remote Artermis (inside remote wildfly):
@Stateless
public class MessageSender {
@Inject
@JMSConnectionFactory("java:/jms/remoteCF")
@JMSPasswordCredential(userName = "jmsuser", password = "jmsuser2020")
private JMSContext context;
@Resource(lookup = "java:/jms/queue/test")
private Queue queue;
public void sendMessage(String message) {
context.createProducer().send(queue, message);
}
}
When I try to deploy the war containing this EJB, I get the error saying that the queue does not exist.
Thank you
Yes. It is possible to inject a JCA-based
pooled-connection-factoryinto your EJB running on WildFly 18 and send a JMS message to a remote WildFly server.