3

EDIT: Here is a gist showing my log. It appears that there is ReceiveMessage and then a preSend on inputChannel:

https://gist.github.com/louisalexander/04e7d95835521efdd15455c98075e2ea

Apologies for being so dense, but I can't seem to figure out how to properly make use of the sqs-message-driven-channel-adapter

In my context file, I am configuring it as such:

<int-aws:sqs-message-driven-channel-adapter
    id="my-message-driven-adapter" sqs="sqs" queues="some-queue-of-mine"
    max-number-of-messages="5" visibility-timeout="200" wait-time-out="10"
    send-timeout="2000" channel="inputChannel" />

I observe that messages are properly making it into some-queue-of-mine (by removing the above bit of code and sending messages to the queue). I then restart my server, enabling the message driven adapter and I observe that all the messages are consumed from the queue, but where did they go? :-/

My expectation was that the messages would be funneled into a DirectChannel named inputChannel:

<int:channel id="inputChannel"/>

That I have a service-activator consuming from as follows:

<int:service-activator ref="myConsumer"
    method='execute' input-channel="inputChannel" output-channel="outputChannel">
    <int:request-handler-advice-chain>
        ...
    </int:request-handler-advice-chain>
</int:service-activator>

But of course, I am never seeing myConsumer get invoked. I imagine my understanding of how the MessageProducer mechanism works is inadequate. Can someone please correct my thinking by providing a trivial example of XML wiring?

Louis Alexander
  • 125
  • 2
  • 11
  • I suggest you to switch on DEBUG for the `org.springframework.integration` category and try to figure out what's going on in logs. Or just share that with us when you think your messages must go to the `inputChannel`. – Artem Bilan Feb 14 '17 at 21:47
  • I have edited my question to supply a gist showing the o.s.integration debug – Louis Alexander Feb 15 '17 at 14:24
  • Sorry, there is no one in your question. – Artem Bilan Feb 15 '17 at 14:25
  • The gist is at the top, here it is again: https://gist.github.com/louisalexander/04e7d95835521efdd15455c98075e2ea – Louis Alexander Feb 15 '17 at 19:08
  • And? What don't you like? There is even `ServiceActivator for` log message meaning that some subscriber on the `inputChannel` is invoked. Try to comment out that `` and see what's going on. Right now your words don't fit to the logs: the message is received and handled by some subscriber on the `inputChannel`. – Artem Bilan Feb 15 '17 at 19:14
  • inputChannel is invoked, but I am not seeing myConsumer get activated. There are no additional subscribers to inputChannel, but *someone* is consuming the message. This is what I don't completely understand. – Louis Alexander Feb 15 '17 at 19:20
  • Just make a search around your config to be sure who consumes your messages – Artem Bilan Feb 15 '17 at 19:21
  • Indeed the logging says that the inputChannel is being consumed by the ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@493f49cd] – Louis Alexander Feb 15 '17 at 19:21
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/135804/discussion-between-louis-alexander-and-artem-bilan). – Louis Alexander Feb 15 '17 at 19:28

1 Answers1

1

According to the Logs the message is consumed by the handler.AbstractMessageHandler (AbstractMessageHandler.java:115) - ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@493f49cd]. Although that might be a fully different story.

SqsMessageDrivenChannelAdapter can be supplied with the errorChannel to handle downstream exceptions. By default it is only logged.

The message sent from that adapter is like:

return new GenericMessage<>(message.getBody(), new SqsMessageHeaders(messageHeaders));

Where that message.getBody() is String. See QueueMessageUtils.createMessage().

So, be sure that your service-activator accepts that String as a paylaod and not any other type.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • This is exactly what I had observed. The message I am trying to deposit on SQS using int-aws:sqs-outbound-channel-adapter is the string "com.my.class.MyObjectMessaged@feedface". So it appears that I need to use a Transformer in front of the int-aws:sqs-outbound-channel-adapter to properly convert it into a string, and then perform the opposite transformation on the input from int-aws:sqs-message-driven-channel-adapter. Let me work on this and then I will post the solution and accept your answer. – Louis Alexander Feb 16 '17 at 13:40
  • Consider to use `ObjectToJsonTransformer` and its opposite - `JsonToObjectTransformer`: http://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#_json_transformers – Artem Bilan Feb 16 '17 at 14:30