I have a wildfly 15 with an external ActiveMQ and use a resource adapter. But i cannot get a connection to a queue to write on.
But I can listen at the queue.
here is my configuration:
ironjacamar.xml:
<admin-objects>
<admin-object class-name="org.apache.activemq.command.ActiveMQQueue"
jndi-name="java:jboss/activemq/queue/HELLOWORLDMDBQueue1234">
<config-property name="PhysicalName">
activemq/queue/HELLOWORLDMDBQueue
</config-property>
</admin-object>
</admin-objects>
ra.xml:
<adminobject>
<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>
Bean.java:
@Resource(lookup = "java:jboss/activemq/queue/HELLOWORLDMDBQueue1234")
private Queue queue;
@Inject
private JMSContext context;
someFunction(){
context.createProducer().send(queue, "hier ist eine nachricht");
}
My listener bean:
@ResourceAdapter("activemq.rar")
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "activemq/queue/HELLOWORLDMDBQueue") })
public class RemoteActiveMQConsumer implements MessageListener {
@Override
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
try {
final String text = ((TextMessage) msg).getText();
System.out.println(text);
} catch (final JMSException e) {
throw new RuntimeException(e);
}
} else {
System.out.println(msg);
}
}
}
pom.xml for Beans contains:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.9.1</version>
<scope>provided</scope>
</dependency>
this is the same version of jar like in the resource adapter.
Reading from the HELLOWORLDMDBQueue
is not a problem, but if i try to send, i get the following output:
Error:
Caused by: javax.jms.InvalidDestinationException: Foreign destination:queue://activemq/queue/HELLOWORLDMDBQueue
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.checkDestination(ActiveMQMessageProducer.java:349)
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:217)
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:206)
at org.apache.activemq.artemis.ra.ActiveMQRAMessageProducer.send(ActiveMQRAMessageProducer.java:142)
at org.apache.activemq.artemis.jms.client.ActiveMQJMSProducer.send(ActiveMQJMSProducer.java:98)
Thanks for help
Similar to your other question on this subject, it appears that you're attempting to use the admin object from the ActiveMQ 5.x JCA resource adapter to configure a JMS queue admin object, but then you're using the ActiveMQ Artemis client to work with that queue. ActiveMQ 5.x and ActiveMQ Artemis are completely different client/server implementations. You can't mix them like that.
You do not need to configure anything related to the ActiveMQ 5.x JCA resource adapter. Simply define your queue in Wildfly's
messaging
subsystem and create connection factories which point to the remote broker.