Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:13:49+00:00 2026-06-13T17:13:49+00:00

While migrating a JBoss 5 application to JBoss AS 7 (7.1.1.FINAL) I have a

  • 0

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:

@Singleton
@Startup
public class StartupBean {

    @PostConstruct
    void atStartup() {
        // TODO load master data cache (takes about 30 seconds)
    }

    @PreDestroy()
    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")
    })
    @DependsOn("StartupBean")
    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 :-)!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:13:50+00:00Added an answer on June 13, 2026 at 5:13 pm

    First i thought inject singleton EJB in mdb would be enough to delay message consumption
    But no, sometimes it would start consuming the message before @PostConstruct of Singleton-ejb completed. So added a method invocation also and it started working

    This worked on glassfish, but i dont see a reason why it shouldnt work on jboss

    Singleton-Ejb:

    @Singleton
    @Startup
    public class SingletonBean {
        private Logger logger = Logger.getLogger(getClass().getName());
    
        private boolean init = false;
    
        public boolean isInit() {
            return init;
        }
    
        @PostConstruct
        public void init() {
            logger.error("singleton init start");
    
            //Do something that takes time here
    
            init = true;
            logger.error("singleton init end ");
        }
    }    
    

    and mdb:

    @MessageDriven(...)
    public class SomeMdb implements MessageListener {
        private Logger logger = Logger.getLogger(getClass().getName());
    
        @EJB
        SingletonBean sb;
    
        @PostConstruct
        public void init() {
            logger.error("mdb init start");
            if (!sb.isInit()) {
                logger.error("never happens");
            }
            logger.error("mdb init complete");
        }
    
        public void onMessage(Message message) {
            logger.error("onMessage start");
        }
    }    
    

    Now it always waits for SingletonBean to complete init before mdb completes init (as seen in log)

    19:51:51,980 [ad-pool-1; w: 3] ERROR SomeMdb       - mdb init start
    19:51:52,122 [ad-pool-4848(4)] ERROR SingletonBean - singleton init start
    19:51:56,316 [ad-pool-4848(4)] ERROR SingletonBean - singleton init end 
    19:51:56,317 [ad-pool-1; w: 3] ERROR SomeMdb       - mdb init complete
    19:51:56,317 [ad-pool-1; w: 3] ERROR SomeMdb       - onMessage start
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while migrating from dojo 1.02 to 1.4 i have encountered a problem with grid.
I have a problem. While migrating from classic pipeline mode to integrated pipeline mode
Came across something strange while migrating to my new server. I have a script
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
I am having troubles while migrating my processing code to processing.js. My processing code
While migrating a legacy application to spring security I got the following exception: org.springframework.beans.factory.BeanCreationException:
While migrating some code to the latest version of F#, included in VS2010 b1,
We've got a weird problem while migrating our app from 1.3.7 to 2.0.0. Our
after migrating from .NET 3.5 to 4.0 i have a strange problem with a
While migrating a program from windows in linux I encountered a problem using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.