WildFly 8.2.0 でも、リモート サーバーにあるリモート jms キューからメッセージを読み取ろうとしています。リモートサーバーで定義されたリモートキュー名は「java:jboss/exported/jms/queue/grinderRemote」です。
読み取りサーバーに同じ名前のキューを定義しましたが、それが正しいかどうかわかりません。
メッセージを読むために、MDB クラスを使用して動的 Web プロジェクトを作成しました。コードは以下です
package it.vr.pms;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
@MessageDriven(name = "ReadJMS1", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "/exported/jms/queue/grinderRemote"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "user", propertyValue = "jmsuser"),
@ActivationConfigProperty(propertyName = "password", propertyValue = "********"),
//@ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),
//@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=http-remoting://192.168.5.124;port=8080")})
public class ReadJMS1 implements MessageListener {
private final static Logger LOGGER = Logger.getLogger(ReadJMS1.class.toString());
public void onMessage(Message rcvMessage) {
TextMessage msg = null;
try {
if (rcvMessage instanceof TextMessage) {
msg = (TextMessage) rcvMessage;
System.out.println("Received Message from queue: " + msg.getText());
} else {
System.out.println("Message of wrong type: " + rcvMessage.getClass().getName());
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
「リーダー」サーバーのログは次のとおりです。
10:26:10,273 INFO [org.hornetq.ra] (default-threads - 1) HQ151000: awaiting topic/queue creation /exported/jms/queue/grinderRemote
10:26:10,336 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /TestJMSReceive
10:26:10,492 INFO [org.jboss.as.server] (ServerService Thread Pool -- 31) JBAS018559: Deployed "TestJMSReceiveEAR.ear" (runtime-name : "TestJMSReceiveEAR.ear")
10:26:10,836 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management
10:26:10,836 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990
10:26:10,836 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 9312ms - Started 326 of 386 services (112 services are lazy, passive or on-demand)
10:26:12,304 INFO [org.hornetq.ra] (default-threads - 1) HQ151001: Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@48b7ee22 destination=/exported/jms/queue/grinderRemote destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=jmsuser password=**** maxSession=15)
どこが間違っているのか理解できません。コメント付きの @ActivationConfigProperty も使用してみましたが、結果は同じでした...
どんな助けでも大歓迎です。
ありがとう
編集
apocalypz によって提案された構成を行いましたが、エラーは次のようになりました。
15:25:47,116 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) JBAS014142: Started message driven bean 'ReadJMS1' with 'hornetq-ra.rar' resource adapter
15:25:47,163 WARN [org.hornetq.ra] (default-threads - 1) HQ152005: Failure in HornetQ activation org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@71996bda destination=queue/LocalServer1Q destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): javax.naming.NameNotFoundException: jms/RemoteConnectionFactory -- service jboss.naming.context.java.jms.RemoteConnectionFactory
RemoteConnectionFactory の代わりにリソース アダプタ hornetq-ra を使用しようとしているようです。または、他のサーバーに RemoteConnectionFactory が見つかりませんか?