我有一个用JBoss EAP 7.2服务器创建的集群环境。以下是详细信息:
我正在AppDeployment Server上部署我的使用者MDB,并且我的JMS在JMS节点(JMS服务器1和JMS服务器2)上配置。我能够将我的消息推送到JMS节点上配置的队列中,但我的消费者不会从此队列中读取消息。以下是域控制器节点上的消息传递子系统的配置:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
<server name="default">
<security enabled="false"/>
<cluster user="admin" password="admin"/>
<journal pool-files="10"/>
<statistics enabled="true"/>
<shared-store-master failover-on-server-shutdown="true"/>
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
<role name="admin" send="true" consume="true" create-durable-queue="true" create-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"/>
<address-setting name="alarms" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue"/>
<address-setting name="DLQ" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue"/>
<address-setting name="ExpiryQueue" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue"/>
<address-setting name="jms.mycom.alarms"/>
<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="netty" socket-binding="messaging">
<param name="use-nio" value="true"/>
</remote-connector>
<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>
<remote-acceptor name="netty" socket-binding="messaging">
<param name="use-nio" value="true"/>
</remote-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
<broadcast-group name="my-broadcast-group" socket-binding="messaging-group" connectors="netty"/>
<discovery-group name="my-discovery-group" socket-binding="messaging-group"/>
<cluster-connection name="my-cluster" address="jms" connector-name="netty" discovery-group="my-discovery-group"/>
<jms-queue name="ExpiryQueue" entries="java:jboss/exported/jms/queue/ExpiryQueue" durable="false"/>
<jms-queue name="DLQ" entries="java:jboss/exported/jms/queue/DLQ" durable="true"/>
<jms-queue name="testQueue1" entries="queue/test1 java:jboss/exported/jms/queue/test1"/>
<jms-topic name="OutboundMessagesTopic" entries="java:jboss/exported/jms/mycom/sal/msg/topic/OutboundMessagesTopic"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa" user="admin" password="admin" statistics-enabled="true"/>
</server>
</subsystem>
下面是为从队列中读取而编写的MDB代码:
package org.jboss.as.quickstarts.mdb;
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 = "HelloWorldQueueMDB", activationConfig = {
// @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/HELLOWORLDMDBQueue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/test1"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "user", propertyValue = "admin"),
@ActivationConfigProperty(propertyName = "password", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class HelloWorldQueueMDB implements MessageListener {
private static final Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString());
/**
* @see MessageListener#onMessage(Message)
*/
public HelloWorldQueueMDB() {
System.out.println("Initializing HelloWorldQueueMDB");
}
public void onMessage(Message rcvMessage) {
System.out.println("inside onMessage");
LOGGER.warning("Message Received..............");
TextMessage msg = null;
try {
System.out.println("message ");
if (rcvMessage instanceof TextMessage) {
msg = (TextMessage) rcvMessage;
LOGGER.info("Received Message from queue: " + msg.getText());
} else {
LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName());
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
我能够得到Initializing HelloWorldQueueMDB
消息,但我没有在我的日志中获得inside onMessage
。
消息是否只是排在队列中?您是否在队列中看到任何消费者?
如果您更改为:
<jms-queue name="testQueue1" entries="queue/test1 java:jboss/jms/queue/test1"/>
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/jms/queue/test1"),