1
Я два управляемых сообщения бобовwildfly 10, JMS, MDB, тема не получает сообщение
@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/тема/Абонент только первая 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("[email protected]@Attempting to acquire connection factory \"" + connectionFactoryString + "\"");
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(connectionFactoryString);
System.out.println("[email protected]@@Found connection factory \"" + connectionFactoryString + "\" in JNDI " + connectionFactory.toString());
String destinationString = passedDestination;
System.out.println("[email protected]@Attempting to acquire destination \"" + destinationString + "\"");
Destination destination = (Destination) namingContext.lookup(destinationString);
System.out.println("[email protected]@@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;
}