Results 1 to 4 of 4

Thread: Using SI during context initialization throws "Dispatcher has no subcribers" exceptn

  1. #1
    Join Date
    Jul 2009
    Location
    Charlotte, NC
    Posts
    131

    Default Using SI during context initialization throws "Dispatcher has no subcribers" exceptn

    We need to cache some results during startup, and we are trying to use SI for same.

    Code:
    <bean id="someClass" class="test.Initializer" init-method="initialize">
    <property name="channel" ref="someDirectChannel" />
    .......
    </bean>
    In initialize, we send a message on "someDirectChannel". An activator picks it, makes a WS call, sends response to a replyChannel, and another activator picks up from that replyChannel, and caches it.

    However, this simple config breaks with "Dispatcher has no subcribers" exception on start-up. As of now, we are caching after the first client call.

    Is there a way to make this work?

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Because subscribers are added during the Lifecycle.start() which means that during your initialization your channel does NOT have any subscribers, hence the exception.
    Also, Lifecycle.stop() will result to a call yo unsubscribe.

  3. #3
    Join Date
    Jul 2009
    Location
    Charlotte, NC
    Posts
    131

    Default

    Thanks Oleg.

    I checked the MessagingAnnotationPostProcessor's postProcessAfterInitialization method, and now the exception makes sense.

    Do you have any suggestion on how to circumvent this, because this seems like a normal usecase, and shouldn't require any custom bean implementing LifeCycle or any other interface?

  4. #4
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    Quote Originally Posted by GPS View Post
    We need to cache some results during startup, and we are trying to use SI for same.

    Is there a way to make this work?
    Yes, if you require caching during startup I'd suggest you use a queue channel. If you don't want a queue channel in the loop after startup, you can have a router that routes to a queue channel during startup, but once started it routes to a direct channel.

    You could have the router implement Lifecycle to pull the switch at the right time.

    There's also plain java and queues if you're more confident doing this in Java rather than xml of course.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •