Announcement Announcement Module
No announcement yet.
Expected Behaviour - Message on a Pub Sub Channel with no subscribers Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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

    [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(
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
    	at $Proxy134.write(Unknown Source)
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(
    	at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(

  • #2

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


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


      • #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"/>