0 Replies Latest reply on Oct 30, 2012 9:36 AM by skowski

    Suspend MDB message processing until @StartupBean has finished initialization


      Hi :-)


      While migrating a JBoss 5 application to JBoss AS 7 (7.1.1.FINAL) I have a problem with a new JMS message driven EJB. Within message processing, some master data fields have to be checked. To enhance performance, this master data shall be preloaded into a cache structure using a @Singleton @Startup EJB, which needs about 30 seconds to load the data.


      My problem is that the queue message processing starts even if the cache has not been fully initialized, causing message validation errors.


      I tried to define a dependency between the MDB and the startup EJB, but as far as I understood the @DependsOn annotation works only with @Singleton EJBs. So it's clear that my solution does not work ;-)


      Startup bean code:





      public class StartupBean {



          void atStartup() {

              // TODO load master data cache (takes about 30 seconds)




          void atShutdown() {

              // TODO free master data cache





      Note: I stripped the real code from the example to make it easier to read :-)


      Message driven bean code:



      @MessageDriven(name="SampleMessagingBean", activationConfig = {

              @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),

              @ActivationConfigProperty(propertyName="destination", propertyValue="jms/SampleQueue"),

              @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")



      public class SampleMessagingBean implements MessageListener {


          public void onMessage(Message message) {

              // TODO validate message using master data cache





      Question: How can I suspend message processing until the startup bean has finished loading the cache?


      Any suggestions greatly appreciated :-)!