0

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

Hasan Tuncay
  • 1,090
  • 2
  • 11
  • 30

1 Answers1

0

I another question I saw that you need to add a clientid to the message driven bean that is different on each cluster instance.

@ActivationConfigProperty(propertyName = "clientID", propertyValue="${com.sun.aas.instanceName}")

So the broker knows that he has to deliver to each listener.

Hasan Tuncay
  • 1,090
  • 2
  • 11
  • 30