0

I'm seeing weird behaviour when sending data through my channels. I'm using SI gateway when sending a message to be processed. The gateway is setup as below

<integration:gateway id="rptPubGateway"
    default-request-channel="rptPubInChannel"
    default-reply-channel="rptOutputAvailableChannel"
    default-reply-timeout="60000"
    service-interface="xxxx.RptPubGateway" />

The reply channel is being set up as a publish/subscribe channel

<integration:publish-subscribe-channel id="rptOutputAvailableChannel" />

The last service that processes the message is being declared as below

<integration:service-activator input-channel="rptOutputAvailableChannel" ref="requestMessageHandler" method="rptIsDone" output-channel="nullChannel"/>

Now, the issue that i have is that while the code works fine most of the time, it fails sometimes. When everything works fine the last component processing my message is PublishSubsChannel

 PublishSubscribeChannel - preSend on channel 'rptOutputAvailableChannel'

but when it fails the last component becomes BridgerHandler

BridgeHandler@e851a798' sending reply Message: 

I should mention that there are no exceptions being thrown while processing my message. (after the failure I can always resend the same message and everything will work OK)

I'm not sure how that BridgerHandler gets created. From what I know this bridge gets created for pub/subs channels but then why I don't see it in the log when everything works fine ?

I'd appreciate any help

user1761377
  • 73
  • 1
  • 6

1 Answers1

0

When you say "fails" what do you mean?

What are the other consumers on rptOutputAvailableChannel?

The BridgeHandler you see is an internal bridge to the message's replyChannel header, which is where the reply ultimately must go. When explicitly sending to rptOutputAvailableChannel, the bridge handler is always invoked to get the reply to the message's temporary reply channel.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Once the _BridgeHandler_ gets called i'm getting 'ChannelResolutionException: no output-channel or replyChannel header available' error. The _rptOutputAvailableChannel_ has a) one service-activator subscriber client (see my original question) that has a nullChannel on the output, b) two other gateways i.e. – user1761377 Jun 27 '14 at 20:02
  • It means the message being sent to the reply-channel has lost it's `replyChannel` header. You can't send arbitrary messages to the reply channel, it must contain the `replyChannel` header from the inbound message - that's how the framework correlates the reply to the request. "Two other gateways..." - you can't have multiple gateways using the same reply channel; replies have to always go to the gateway that initiated the flow. – Gary Russell Jun 27 '14 at 20:14
  • **Re: "replyChannel header"**, i'm not sending any arbitrary message to my channel, but i agree that somehow these headers get lost. Is there any way to debug what changes my message ? **Re:"Two other gateways"**, these are different entry points for the same payload i.e. gateway1 takes as an input XML, while gateway2 gets called from some other service with the same payload (XML). In both cases the processing chanin finishes calling the same service activator (thats why my replyChannel has been declared as pub/subs) – user1761377 Jun 30 '14 at 10:11
  • Right, but you can't have multiple gateways with the same reply channel - otherwise every gateway will get the reply from a request. Given the way the bridge works, it will work ok but (in newer versions of the framework) you will get warnings about late replies from the other instances. You would be much better off not declaring a reply-channel and let the framework take care of the routing. Just don't include an `output-channel` on the final endpoint. Turn on DEBUG logging and you should see where the `replyChannel` header is getting lost. – Gary Russell Jun 30 '14 at 13:19