0 Replies Latest reply on Jul 8, 2014 4:04 PM by rcd

    How to build a cluster singleton MDB?


      For reasons that are complicated, I need to create a cluster singleton MDB (i.e. exactly one consumer for a message queue across the entire cluster, with automatic failover).


      I think I've found most of the ingredients required to do this. I can set the maxSession ActivationConfigProperty to 1 on the MDB, which will ensure that each node only has 1 instance of the MDB. I can use the DeliveryActive annotation (see WFLY-878) to make sure that the MDB doesn't start getting messages until I want it to. And I can use the singleton service API described here to ensure that a service is running on exactly one node.


      The catch is that I'm not sure how to toggle delivery on and off. I've looked at the quickstart example for the singleton service API, which implements a cluster-wide timer. Notably, the example does not actually start/stop the EJB containing the timers, it just calls a method on the EJB that creates/destroys the timers. It seems like there should be some way to obtain the MessageDrivenComponent, which has the startDelivery() and stopDelivery() methods, in my singleton service. But I can't figure out how I would do that. Does anyone know if/how I can do that?


      Another idea that occurred to me was to use the native management API to issue those operations, but getting a ModelControllerClient requires knowing which interface and port the WildFly management socket-binding is using, so I'd rather not do that.