Results 1 to 4 of 4

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

  1. #1
    Join Date
    Nov 2008
    Location
    London,UK
    Posts
    299

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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

  3. #3
    Join Date
    Nov 2008
    Location
    London,UK
    Posts
    299

    Default

    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. #4
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •