PDA

View Full Version : DI : Dispatcher has no subscribers



wims.tijd
Feb 28th, 2010, 05:53 AM
wrote a @Test for my si:gateway : works fine

now i wanted to use this gateway :


@Resource
CriteriaGateway cg;

@PostConstruct
void postConstruct() {
cg.read();}

at this point : throws MessageDeliveryException,

removed @PostConstruct and now no problem with :

public void onApplicationEvent(ContextRefreshedEvent event) {
postConstruct();
}

how can i postpone any methodcalls until si is ready ?

iwein
Feb 28th, 2010, 12:30 PM
You shouldn't be sending messages before the whole system is up. @PostConstruct is part of the initialization, not the use of the system, so it should not be sending messages.

If you need a messaging system from @PostConstruct it is a different system then the one you're still constructing. You could do this by creating a parent context containing the messaging system and reusing it in the system you're starting... I'm not sure if that wouldn't add too much complexity.