0 Replies Latest reply on Mar 19, 2007 10:00 PM by Gilles Dubuc

    Message-driven bean static field over cluster

    Gilles Dubuc Newbie

      I've been using JBoss for a few weeks now and I ran into a tricky situation that I'm not sure will work in a clustered environment.

      I have a message driven bean class, as I understand it when it's deployed JBoss instantiates a pool of these beans listening to the queue I've specified. This mdb class applies rules (with drools) to their incoming messages. What I want to do is have a mechanism for telling all the instances of this class to update their rulebase when I want them to.

      The solution I came up with is that in addition to the MBeans using this class listening to the queues I need, I have an extra MBean listening to an update queue (still of the same single MDB class I was mentioning above). When an update message is received, the instance that picks it up is in charge of telling all the other instances of the same MDB class to update themselves.

      My current way of doing this is to hold a list of instances as a static field in the MDB class and make the one instance that receives the update message to go through the static list of instances and call the update method on each of them.

      Now, will the static field work in a cluster? From what I've read it shouldn't but I'm not sure, especially since JBoss does all the clustering of the message driven beans in the background.

      If the static field won't work across machines, then how could I find a way to notify all the instances of that message driven bean to do something? Of course a JMS topic would be great, but these beans are listening to queues for the rest of what they do, and as far as I know a message driven bean can't listen to a queue and a topic at the same time. Maybe a JNDI call, but wouldn't that create a lot of network traffic betwen machines in the cluster?