How to acknowledge a message through a program using AMQP / Spring integration

1) The server sends a message to the client.

2) The incoming channel adapter is configured to wait for the user confirmation mode "MANUAL" from the user

3) The "TaskBundlereceiver" bean implements the "ChannelAwareMessageListener", and in the implementation method I carry out a message confirmation.

I do not see the "TaskBundlereceiver" running. Did I miss something?

Below are the configuration details of the steps that I have explained.

Rate your entries.

@Override public void onMessage(org.springframework.amqp.core.Message message, Channel channel) throws Exception { logger.debug("In onMessage method of the channel aware listener. message =["+message.getBody().toString()+"]"); channel.basicAck(message.getMessageProperties().getDeliveryTag(), true); } 

XML configuration:

  <!-- Channel that receives the task bundle from the server for execution --> <int:channel id="fromKServerChannel"/> <int-amqp:inbound-channel-adapter id="taskBundleReceiverAdapter" channel="fromKServerChannel" error-channel="taskBundleErrorChannel" acknowledge-mode="MANUAL" expose-listener-channel="true" queue-names="kanga_task_queue" connection-factory="connectionFactory" concurrent-consumers="20"/> <int:chain input-channel="fromKServerChannel" output-channel="nullChannel"> <int:service-activator ref="taskBundleReceiver" method="onMessage"/> <int:service-activator ref="taskBundleExecutor" method="executeBundle"/> </int:chain> 
+4
source share
1 answer

This does not work; A listener is an adapter, not a service called through a service activator. The adapter does not currently support manual transmission of a channel to a client. The expose-listener-channel attribute is used for use in transactions, so a tiny stack rabbit template may be involved in a transaction.

Why do you want MANUAL? AUTO (default) means that ack will be executed automatically by the container when the stream returns normally; if your service throws an exception, the message will be unloaded.

So how to manage ack.

If you really want to use MANUAL acks, you will need to use <rabbit:listener-container/> to directly call your BundleReceiver task. He could then send a message to the performer using a messaging gateway.

+5
source

Source: https://habr.com/ru/post/1443306/


All Articles