我有一个带有外部activemq的wildfly 15并使用一个资源适配器。但我无法连接到要写入的队列。
但我可以在队列里听。
以下是我的配置:
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");
}
我的听众比恩:
@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包含:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.9.1</version>
<scope>provided</scope>
</dependency>
这与资源适配器中的jar相同。
从
HELLOWORLDMDBQueue
不是问题,但如果我尝试发送,则会得到以下输出:
错误:
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)
谢谢你的帮助