我正在尝试将Wildfly 13 - Instance连接到独立的Artemis ActiveMQ以从中生成和使用消息。因此,我遵循了 Wildfly 13 文档和 Artemis ActiveMQ 文档的相关部分。此外,我尝试使用本教程并使用JMS 2.0 Simplified-API对其进行了一些自定义。
当我向/produce 发送有效负载时,没有引发异常。所以我相信JNDI存在问题。我已经监视了Wireshark正在进行的网络活动,并且能够看到Wildfly和Artemis ActiveMQ之间的软件包交换。野蝇不断尝试访问远程队列,但以
AMQ11901 7: Queue does not exist
直到现在,我都无法弄清楚为什么会发生这种情况。
这是我到目前为止所拥有的:
野蝇配置(单机-全公顷.xml(
//...
<outbound-socket-binding name="ImportantMessages-remote">
<remote-destination host="127.0.0.1" port="61616"/>
</outbound-socket-binding>
//...
<subsystem xmlns="urn:jboss:domain:messaging-activemq:3.0">
<server name="default">
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10" redistribution-delay="1000"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<remote-connector name="ImportantMessages-remote" socket-binding="ImportantMessages-remote"/>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-connector>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
<broadcast-group name="bg-group1" jgroups-cluster="activemq-cluster" connectors="http-connector"/>
<discovery-group name="dg-group1" jgroups-cluster="activemq-cluster"/>
<cluster-connection name="my-cluster" address="jms" connector-name="http-connector" discovery-group="dg-group1"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
<pooled-connection-factory name="ImportantMessages-remote" entries="java:/jms/remoteIM" connectors="ImportantMessages-remote"/>
</server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<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.ImportantMessages" value="ImportantMessages"/>
</environment>
</external-context>
<lookup name="java:/ImportantMessages" lookup="java:global/remoteContext/ImportantMessages"/>
</bindings>
<remote-naming/>
</subsystem>
消息生产者资源
@Stateless
@Path("produce")
public class MessageProducerResource {
private static final Logger LOG = Logger.getLogger(MessageProducerResource.class.getName());
@Inject
@JMSConnectionFactory("java:/jms/remoteIM")
private JMSContext jmsContext;
@Resource(lookup = "java:global/remoteContext/ImportantMessages")
private Queue queue;
@POST
public void sendMessage(String txt) {
jmsContext.createProducer().send(queue, txt);
LOG.info("Sent message containing "" + txt + "" to " + queue);
}
}
我相信这些是相关的代码片段。如果您需要任何进一步的信息,请随时询问。有没有人遇到过类似的问题,可以帮助我?
可能需要在artemis 代理上设置安全凭据,并将用户/密码添加到池连接工厂。
<pooled-connection-factory name="ImportantMessages-remote" entries="java:/jms/remoteIM" connectors="ImportantMessages-remote" user="user123" password="Password123"/>