[英]Wildfly JMS Topic using Message Driven Beans. Get one MDB per server
[英]wildfly 10, JMS, MDB, topic does not receive message
我有两个消息驱动的bean
@MessageDriven(name = "SubscribersTopicQueueMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/topic/Subscribers"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class SubscribersTopicQueueMDB implements MessageListener {
private final static Logger LOGGER = Logger.getLogger(SubscribersTopicQueueMDB.class.toString());
public SubscribersTopicQueueMDB() {
System.out.println("Topic: SubscribersTopicQueueMDB INIT ");
}
and
@MessageDriven(name = "SubscribersTopicSecondMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/topic/Subscriber"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class SubscribersTopicSecondMDB implements MessageListener {
private final static Logger LOGGER = Logger.getLogger(SubscribersTopicSecondMDB.class.toString());
public SubscribersTopicSecondMDB() {
System.out.println("TOPIC: SubscribersTopicSecondMDB (Second) INIT ");
}
当我向主题jms / topic / Subscriber发送消息时,仅收到第一个MDB消息,第二个MDB不接收任何消息。 我怎么能改善这个?
我简单的客户
public static void sendTextMessage(String message, String passedDestination) {
if (message == null || passedDestination == null) {
return;
}
Context namingContext = null;
try {
String userName = JMS_DEFAULT_USERNAME;
String password = JMS_DEFAULT_PASSWORD;
// Set up the namingContext for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, JMS_INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, JMS_PROVIDER_URL);
// env.put(Context.SECURITY_PRINCIPAL, userName);
// env.put(Context.SECURITY_CREDENTIALS, password);
namingContext = new InitialContext(env);
// Perform the JNDI lookups
String connectionFactoryString = JMS_DEFAULT_CONNECTION_FACTORY;
System.out.println("+@@Attempting to acquire connection factory \"" + connectionFactoryString + "\"");
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(connectionFactoryString);
System.out.println("+@@@Found connection factory \"" + connectionFactoryString + "\" in JNDI " + connectionFactory.toString());
String destinationString = passedDestination;
System.out.println("+@@Attempting to acquire destination \"" + destinationString + "\"");
Destination destination = (Destination) namingContext.lookup(destinationString);
System.out.println("+@@@Found destination \"" + destinationString + "\" in JNDI");
int count = 2;
String content = message;
//System.out.println("userName " + userName);
//System.out.println("password " + password);
try (JMSContext context = connectionFactory.createContext()) {
System.out.println("***************Sending to " + destinationString + " messages with content: " + content + " *********************");
context.createProducer().send(destination, content);
}
//return true;
} catch (NamingException e) {
e.printStackTrace();
} finally {
if (namingContext != null) {
try {
namingContext.close();
} catch (NamingException e) {
e.printStackTrace();
}
}
// return false;
}
发现我的错误一个话题听jms / topic / Subscriber第二个jms / topic / Subscribers.improved。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.