I have created a topic factory and a topic pool on a glassfish 3.1.2.2 cluster. The cluster has a embedded conventional with a master broker jms installed.
After sending a message into the pool I thought all the messsage driven beans that are connected to the pool on the machine would receive the message. But only one cluster instance gets the message rotativly. I most cases this is very good. But here I would like to receive it every where.
How must I setup the cluster jms to broadcast to all listening MDB's. I tought a TOPIC would do exacly that.
@Resource(mappedName="jms/TestTopicFactory")
private TopicConnectionFactory topicConnectionFactory;
@Resource(mappedName="jms/TestTopicPool")
private Topic topic;
----
TextMessage topicmsg = session.createTextMessage("topic " + i++);
TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();
TopicSession topicSession = topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
TopicPublisher publisher = topicSession.createPublisher(topic);
publisher.publish(topicmsg);
----
@MessageDriven(
mappedName="jms/TestTopicPool",
activationConfig = { @ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Topic")
})
public class MessageDrivenBeanTopic implements MessageListener {
@Override
public void onMessage(Message message) {
try {
TextMessage text = (TextMessage)message;
System.out.println(text.getText());
} catch (Throwable t) {
t.printStackTrace();
}
}
Thanks