Announcement Announcement Module
Collapse
No announcement yet.
Using SI during context initialization throws "Dispatcher has no subcribers" exceptn Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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?

      Comment


      • #4
        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.

        Comment

        Working...
        X