Announcement Announcement Module
Collapse
No announcement yet.
Expected Behaviour - Message on a Pub Sub Channel with no subscribers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Expected Behaviour - Message on a Pub Sub Channel with no subscribers

    I am using Spring Integration+Spring Dm server 2.0 +Spring Batch

    In one of my spring batch jobs writer i am trying - to use a gatewayProxyFactory bean and putting a message into a pub sub channel.

    This pub sub channel is exposed as a osgi service. There are other bundle which subscribe to this pub sub channel and have respective service activators.

    Now when there are no subscribers , what the expected behavior ? Will a subscriberNotAvalibale exception be thrown , or message on teh channel will simply be discarded.


    I tried this sample with spring batch+spring dm 2.0+spring integration 1.3

    But i get teh following exception when there are no subscribers

    Code:
    [2010-02-03 16:27:10.046] edulerFactoryBean#0_Worker-9 org.springframework.batch.core.step.AbstractStep                  Encountered an error executing the step org.springframework.integration.message.MessageDeliveryException: failed to send Message to channel
    	at org.springframework.integration.gateway.AbstractMessagingGateway.send(AbstractMessagingGateway.java:129)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:206)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:172)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy134.write(Unknown Source)
    	at com.pg.batch.SampleWriter.write(SampleWriter.java:18)
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:156)
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:137)
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:252)
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:178)
    	a

  • #2
    Sudheerk

    The message you see is expected behavior when you are dealing with GatewayProxyFactoryBean

    First, the default behavior of messages sent to a pub-sub channel is that they are dropped. However direct invocation of channel.send(..) method returns boolean which will be 'true' only in a case if the message reached at least one subscriber. So you can always check for it.
    When you using Gateway, this boolean value will be checked by MessageChannelTemplate due to the fact that it now has to deal with reply message as well and if channel.send(..) equals 'false', the exception you are showing will be raised.
    Code:
    if (!this.doSend(request, channel)) {
    			throw new MessageDeliveryException(request, "failed to send message to channel");
    }
    Glad to see you guys are using SI - all that fun in Hyderabad payed off
    Cheers

    Comment


    • #3
      Nice to hear from you Oleg & thanks again for the quick reply.

      We are already using SI for our asynchronous communication to achieve SOA in our production environment.

      Now we are looking to use SI along with Spring batch for out offline Batch jobs, where we need to send and receive data to different partners in different formats.

      Comment


      • #4
        I've come across the need for a pub-sub channel that doesn't require subscribers a few times before. You can do this with a <bridge output-channel="nullChannel"/>

        Comment

        Working...
        X