Message Bean Design Question

Discussions

EJB design: Message Bean Design Question

  1. Message Bean Design Question (3 messages)

    I have a Message Bean, which is listening on a queue, and processing input requests. This Message Bean is allowed to listen only during a certain time period (9.00 am - 9.00 pm). Is there any way to de-activate the Message Bean from listening to the queue? One idea was to send it a 'Shutdown' message, which could be used to deactivate it. But how does one deactivate a Message Bean listener?

    Thanks in advance.

    Threaded Messages (3)

  2. Message Bean Design Question[ Go to top ]

    I don't think you can deactivate a MDB, but you can always program some time dependent logic in your bean. In this way, your MDB can consume the message from queue, and also prevent the request from being processed.
  3. There is a service you can build which would tell you whether to process this message or not (based on time, may be message type etc). Now this service can be called from both producer side (producer of message) or the consumer side (MDB). Downfall of consumer side is that you still process the message, call the service (which tells you to process the message or not).
    More desirable will be on producer side, sooner you do that validation (whether the time period is between 9am to 9pm), better it would with lesser problems down the line (less network traffic etc).

    Once the service tells you NOT to process the message, you can either persist the message in the database (which a job can pick up) or you can send the message back to the same queue with a delay (I think delay is in JMS Header).

    Another deployment solution is through JMX (using MBean) you can undeploy the MDB. I mean like a cron job can run, use MBean to undeploy the MBD. Then another one can run to redeploy back the MDB
  4. Mohit wrote:
    Another deployment solution is through JMX (using MBean) you can undeploy the MDB. I mean like a cron job can run, use MBean to undeploy the MBD. Then another one can run to redeploy back the MDB

    I am intrigued by this option. Has anyone done this before?

    Thanks.