skowski [
https://community.jboss.org/people/skowski] created the discussion
"Suspend MDB message processing until @StartupBean has finished initialization"
To view the discussion, visit:
https://community.jboss.org/message/772984#772984
--------------------------------------------------------------
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:
{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
}
}
{code}
Note: I stripped the real code from the example to make it easier to read :-)
Message driven bean code:
{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
}
}
{code}
Question: How can I suspend message processing until the startup bean has finished loading
the cache?
Any suggestions greatly appreciated :-)!
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/772984#772984]
Start a new discussion in EJB3 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]