Announcement Announcement Module
Collapse
No announcement yet.
Effect of Order of elements in the spring integration context file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Effect of Order of elements in the spring integration context file

    Hi everyone ,

    If i execute my program with below context file both the service activator and file outbound adapter gets called .


    <int:channel id="input"></int:channel>

    <int:service-activator id="SAsayHellow" input-channel="input" output-channel="SAoutput1" ref="test" method="sayHellow" ></int:service-activator>

    <int:channel id="SAoutput1"></int:channel>

    <int:service-activator id="SAsayBye" input-channel="SAoutput1" output-channel="channel5" ref="test" method="sayBye" ></int:service-activator>


    <int-file:outbound-channel-adapter id="fileoutbound1" directory="C:\TestProject\Test" channel="SAoutput1"></int-file:outbound-channel-adapter>

    But if i execute my program with service activator as last element as below only my file outbound adapter will be called and my service activator doesnt get called ... Can anyone explian why we have this behavior based on the order of service activator or file outbound adapter

    <int:channel id="input"></int:channel>

    <int:service-activator id="SAsayHellow" input-channel="input" output-channel="SAoutput1" ref="test" method="sayHellow" ></int:service-activator>

    <int:channel id="SAoutput1"></int:channel>

    <int:service-activator id="SAsayBye" input-channel="SAoutput1" output-channel="channel5" ref="test" method="sayBye" ></int:service-activator>


    <int-file:outbound-channel-adapter id="fileoutbound1" directory="C:\TestProject\Test" channel="SAoutput1"></int-file:outbound-channel-adapter>

    <int:service-activator id="SAsayBye" input-channel="SAoutput1" output-channel="channel5" ref="test" method="sayBye" ></int:service-activator>

  • #2
    You are using a DirectChannel which is a P2P channel which means only one subscriber will receive the message. If you are looking for PUB-SUB instead of P2P than you should have your 'SAoutput1' channel configured as publish-subscribe-channel

    Comment


    • #3
      But if i make the channel as publish subscribe channel its giving a error

      org.springframework.integration.MessageDeliveryExc eption: Dispatcher has no subscribers.

      Is it mandatory to add channel.subscribe() method in the code or is it possible to configure the same in xml

      Comment


      • #4
        Can you post the complete stack trace?

        Comment


        • #5
          Exception in thread "main" org.springframework.integration.MessageDeliveryExc eption: ADarsh Dispatcher has no subscribers.
          at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :104)
          at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:9 7)
          at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:61)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:128)
          at org.springframework.integration.core.MessagingTemp late.doSend(MessagingTemplate.java:290)
          at org.springframework.integration.core.MessagingTemp late.send(MessagingTemplate.java:149)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendMessage(AbstractRep lyProducingMessageHandler.java:175)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendReplyMessage(Abstra ctReplyProducingMessageHandler.java:159)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.produceReply(AbstractRe plyProducingMessageHandler.java:124)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleResult(AbstractRe plyProducingMessageHandler.java:118)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:100)
          at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:78)
          at org.springframework.integration.dispatcher.Broadca stingDispatcher.invokeHandler(BroadcastingDispatch er.java:105)
          at org.springframework.integration.dispatcher.Broadca stingDispatcher.dispatch(BroadcastingDispatcher.ja va:96)
          at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:61)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:128)
          at org.springframework.integration.core.MessagingTemp late.doSend(MessagingTemplate.java:290)
          at org.springframework.integration.core.MessagingTemp late.send(MessagingTemplate.java:149)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendMessage(AbstractRep lyProducingMessageHandler.java:175)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendReplyMessage(Abstra ctReplyProducingMessageHandler.java:159)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.produceReply(AbstractRe plyProducingMessageHandler.java:124)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleResult(AbstractRe plyProducingMessageHandler.java:118)
          at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:100)
          at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:78)
          at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :110)
          at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:9 7)
          at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:61)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
          at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:128)
          at com.bosch.test.Test.main(Test.java:24)

          Comment


          • #6
            Have you got subscriber for channel5? From the exception it is clear some channel with a UnicastingDispatcher is not having a subscriber (e.g. DirectChannel) as opposed to a PublishSubscribeChannel with a BroadcastingDispatcher

            Try adding a subscriber for channel5 and check.
            Last edited by Amol Nayak; Nov 30th, 2011, 12:05 AM.

            Comment


            • #7
              Thanks a lot Amol it worked fine after adding the subscriber . Can you please explian the concept under this .

              Comment


              • #8
                Hi Adarsh,
                Channels use Dispatchers internally to dispatch messages to their subscribers.

                Channels like DirectChannel use UnicastingDispatcher which dispatches to one subscriber. Where as PublishSubscribeChannel use BroadcastingDispatcher which will be dispatching the message to multiple subscribers subscribed.
                Since you had two subscribers for a channel, oleg suggested you to use PublishSubscribeChannel instead of the DirectChannel you were using.

                If you look at the stack trace, the BroadCastingDispatcher is seen somewhere around the center of the trace and this exception is thrown from a UnicastingDispatcher which tells us the message went past this PublishSubscribeChannel to the service activator and this exception was thrown from some DirectChannel later in the flow. Which leaves us with channel5.

                Does that answer your question?

                Comment


                • #9
                  Thanks a lot amol that was helpfull

                  Comment

                  Working...
                  X