0

I have registered an AsyncHandler and also added a success-channel to an SQS outbound flow. The success-channel has a int:logging-channel-adapter endpoint. However I am not able to see any logs from this adapter. The AsyncHandler is able to receive the call-backs but nothing on the success-channel. In the SqsMessageHandler I see that we are setting an output channel in the obtainAsyncHandler method, but I did not see the success-channel set anywhere. Am I missing something? I would prefer using the success and failure channels and not AsyncHandler call-back Impl to avoid having AWS specific code in my classes.

Also my <int-aws:sqs-outbound-channel-adapter> is inside a <int:chain> which has no output channel, since the flow ends when the message is sent.

EDIT - Added Config This is the only way I can get it to log the callback.

    <int:channel id="chainChannel" />
    <int:channel id="successChannel" />
    <bean class="ServiceTransformer" id="serviceTransformer" />
    <int:chain input-channel="serviceChannel" id="sendToServiceSqsChain" output-channel="chainChannel">
        <int:transformer ref="serviceTransformer" method="transform" />
        <int:header-filter header-names="config" />
        <int-aws:sqs-outbound-channel-adapter sqs="amazonSQS" queue="some-queue" async-handler="sqsPublishCallbackHandler" success-channel="successChannel"/>
    </int:chain>

    <int:logging-channel-adapter log-full-message="true" channel="chainChannel" />

Here I can just use the same channel in both chain (outbound channel) and sqs-outbound (success-channel)

Unable to get it to work like below:

        <int:channel id="successChannel" />
        <bean class="ServiceTransformer" id="serviceTransformer" />
        <int:chain input-channel="serviceChannel" id="sendToServiceSqsChain" >
            <int:transformer ref="serviceTransformer" method="transform" />
            <int:header-filter header-names="config" />
            <int-aws:sqs-outbound-channel-adapter sqs="amazonSQS" queue="some-queue" async-handler="sqsPublishCallbackHandler" success-channel="successChannel"/>
        </int:chain>
    
        <int:logging-channel-adapter log-full-message="true" channel="successChannel" />
Nikhil
  • 345
  • 2
  • 13

1 Answers1

1

The <int-aws:sqs-outbound-channel-adapter> component is one-way, therefore there is no outputChannel option expose. However the target class is AbstractMessageProducingHandler. To avoid code duplication we reuse an existing outputChannel internally for that AsyncHandler.

In the XML parser we just remap one to another:

IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "success-channel", "outputChannel");

You probably don't see anything in logs because you need to adjust logging config respectively for the appropriate category and level.

UPDATE

According my testing this is definitely not possible to configure such a component with XML DSL within the <chain>. That <int-aws:sqs-outbound-channel-adapter> has to be presented outside of the <chain>.

Consider to more your configuration to Java DSL instead: https://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/dsl.html#java-dsl.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I think the issue is that my is inside a . Hence the message is not routed to the success-channel. It(success-channel) works only when I add an output-channel on the chain.How to handle this scenario without creating an output channel on the ? – Nikhil Aug 24 '20 at 20:46
  • Move it outside of the `chain`. Would be great to see your configuration for confirmation. Otherwise it’s all speculation – Artem Bilan Aug 24 '20 at 20:53
  • I have added the config via EDIT to the main question, request you to review it. – Nikhil Aug 24 '20 at 21:06
  • OK. Anyway. How does it work if it is configured outside of the `chain`? – Artem Bilan Aug 24 '20 at 21:41
  • See an UPDATE in my answer. – Artem Bilan Aug 24 '20 at 23:14
  • Thanks for the update. Outside the 'chain' it works fine. I will try the DSL approach. Just a thought - as an enhancement should the framework fallback to create a new success-channel when no existing output channel is found? – Nikhil Aug 25 '20 at 08:11
  • It’s not related. The chain has a logic to set its internal channels into handlers for forwarding. So, whatever we provide is overridden – Artem Bilan Aug 25 '20 at 13:16