【发布时间】:2018-10-24 04:06:32
【问题描述】:
我有一个带有队列的独立远程 Artemis 服务器,我想配置 WildFly 以便通过 WildFly 本身连接该队列。 版本为 WildFly 12.0.0.Final 和 Artemis 2.5.0。
在 Artemis 上,我在 broker.xml 文件中配置了一个队列,如下所示:
<addresses>
<address name="DemoQueue">
<anycast>
<queue name="DemoQueue" />
</anycast>
</address>
</addresses>
然后我在 WildFly 上配置了一个 pooled-connection-factory 创建:
- 一个outbound-socket-binding指向远程消息服务器
- 一个 remote-connector 引用 outbound-socket-binding
- 一个 pooled-connection-factory 引用远程连接器
我在 standalone-full.xml 文件中的最终配置是这样的:
<server>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<outbound-socket-binding name="remote-artemis">
<remote-destination host="localhost" port="61616"/>
</outbound-socket-binding>
</socket-binding-group>
<subsystem xmlns="urn:jboss:domain:messaging-activemq:3.0">
<server name="default">
...
<remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
<pooled-connection-factory name="remote-artemis" entries="java:/jms/RemoteArtemisCF" connectors="remote-artemis"/>
</server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/federation/remotequeue" 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://localhost:61616"/>
<property name="queue.queues/DemoQueue" value="DemoQueue"/>
</environment>
</external-context>
<lookup name="java:/DemoQueue" lookup="java:global/federation/remotequeue/DemoQueue"/>
</bindings>
<remote-naming/>
</subsystem>
</server>
如下创建消费者我无限期地收到此消息
AMQ151004: Instantiating javax.jms.Queue "DemoQueue" directly since UseJNDI=false.
@ResourceAdapter("remote-artemis")
@MessageDriven(mappedName = "DemoQueue",activationConfig =
{
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "DemoQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})
//@Component
public class Receiver implements MessageListener {
...
}
创建一个传递 JNDI 名称的消费者来查找队列我收到此错误WFLYNAM0062: Failed to lookup DemoQueue [Root exception is java.lang.RuntimeException: javax.naming.NameNotFoundException: DemoQueue]。
这是生产者的代码: 公共类生产者{
private Logger logger = LogManager.getLogger(this.getClass());
@Resource(lookup="java:/jms/RemoteArtemisCF")
private ConnectionFactory connectionFactory;
@Resource(lookup="java:/DemoQueue")
private Queue queue;
public void simpleSend(String msg) {
Connection connection = null;
Session session = null;
try {
try {
connection = connectionFactory.createConnection();
connection.start();
// Create a Session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create a MessageProducer from the Session to the Topic or Queue
MessageProducer producer = session.createProducer(queue);
// Create a message
TextMessage message = session.createTextMessage(msg);
// Tell the producer to send the message
producer.send(message);
logger.debug("Message sent");
} finally {
// Clean up
if (session != null) session.close();
if (connection != null) connection.close();
}
} catch (JMSException e) {
logger.error(e.getMessage(), e);
}
}
}
谁能帮我找到正确的配置或源代码?
提前致谢。
【问题讨论】:
-
您找到解决方案了吗?
-
不,我没有找到解决办法
标签: jms wildfly activemq-artemis