Announcement Announcement Module
Collapse
No announcement yet.
Looking for a way to stop a DirectChannel Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for a way to stop a DirectChannel

    I am looking for a way to stop a DirectChannel from getting messages
    I am not using any *inbound*, just sending directly to the channel so not possible to use SmartLifecycle.
    I am using Spring Integration 2.1.0.RELEASE and sending Message<String> messages using:
    Code:
    [..]
    notificationChannel.send(message);[..]
    Is there a way to pause/stop/resume the flow?

    EDIT:
    Or is it possible to stop/pause/resume a service activator

    Thanks in advance
    Last edited by artafinde; Oct 23rd, 2012, 08:39 AM. Reason: alternative solution

  • #2
    The first thing that comes to mind is to add a ChannelInterceptor and provide a configurable flag on that so that the preSend() method returns FALSE when the interceptor's flag is in the OFF position.

    However, there might be a way to handle this elsewhere in the flow (upstream or downstream from the channel itself). Can you explain a bit about your flow and the rationale for being able to deactivate it?

    Thanks,
    Mark

    Comment


    • #3
      Hi!
      pause/stop/resume the flow
      is equals to
      stop/pause/resume a service activator
      Any message flow starts from consumer(subscriber) on the channel.
      So, you go right way: you should just stop your endpoint (PollingConsumer or EventDrivenConsumer) from it's SmartLifecycle abilities.
      it will be enough to add an 'id' attribute for your <service-activator> and invoke it, e.g. from <control-bus>:
      HTML Code:
      <transformer input-channel="sendStopCommandChannel" output-channel="controlBusChannel"
      				 expression="'@myServiceActivator.stop()'"/>
      However be careful with that, you may end up with this one:
      Code:
      org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel ...
      when you unsubscribe from chennels who implement AbstractSubscribableChannel.

      Hope that help

      Take care,
      Artem

      Comment


      • #4
        Cleric thanks for your answer, I used something similar combine what you suggested and the examples:
        https://github.com/SpringSource/spri...sDemoTest.java

        I am getting the controlBusChannel and sending a genericMessage to stop the serviceActivater.

        The service activator is connected to

        Code:
        <si:channel id="notificationChannel"/>
        <si:channel id="enrichingChannel"/>
        so I don't think I will have problem with AbstractSubscribableChannel since both are org.springframework.integration.core.MessageChanne l (right?)

        Thanks again

        Comment


        • #5
          (right?)
          No
          <si:channel id="notificationChannel"/>
          <si:channel id="enrichingChannel"/>
          Both are DirectChannel.
          However you're right, I had to say so:
          Be careful around SubscribableChannel implementations!

          Does it work for you now?

          Comment


          • #6
            Originally posted by Cleric View Post
            No

            Both are DirectChannel.
            Oops, good to know
            Originally posted by Cleric View Post
            However you're right, I had to say so:
            Be careful around SubscribableChannel implementations!

            Does it work for you now?
            Yeah seems to be working on some first tests. I will come back if not, thanks!

            Comment

            Working...
            X