Spring AMQP publisher confirms in a amqp outbound gateway -
i using spring amqp publishing messages rabbitmq using outbound gateway. have set publisher confirms on connection factory , added custom callback listener.
the problem correlationdata null , can't add correlation data on outbound gateway. applicable outbound channel adapter.
for outbound gateway publisher confirms work?
edit configuration below. looked through si code , yes, publisher confirms, enabled. problem when receive nack? because of outbound gateway don't need correlation id handle response, there thread listening on temporary reply queue response.
what point of using publisher confirms outbound gateway? if no response coming or rabbit nodes go down encounter exceptions. there scenario when lose messages?
<rabbit:connection-factory id="rabbitconnectionfactory" host="someip" port="5672" username="username" password="password" virtual-host="vhost" publisher-confirms="true"/> <rabbit:admin connection-factory="rabbitconnectionfactory"/> <rabbit:template id="amqptemplate" connection-factory="rabbitconnectionfactory" confirm-callback="messagesconfirmcallback"/>
<int-amqp:outbound-gateway request-channel="channel" amqp-template="amqptemplate" exchange-name="exchange" routing-key-expression="headers['queuespecific']+'.queue'"> <amqp:request-handler-advice-chain> <ref bean="retryadvice"/> </amqp:request-handler-advice-chain> </int-amqp:outbound-gateway>
and callback simple
@component public class messagesconfirmcallback implements rabbittemplate.confirmcallback { private final static logger logger = loggerfactory.getlogger(messagesconfirmcallback.class); @override public void confirm(correlationdata correlationdata, boolean ack) { if(ack){ logger.info("ack received"); } else{ logger.info("nack received"); } } }
this
unfortunately, don't see easy work around gateway; underlying rabbittemplate
supports adding correlation data on send()
methods, not sendandreceive
methods.
the 2 options can think of (1) use pair of outbound , inbound adapters (instead of gateway), you'll have own request/reply correlation in case.
alternatively (2), use rabbittemplate.execute()
, in doinrabbit
callback, add code similar in rabbittempalate.dosendandreceive
, while setting correlation data done in dosend()
.
i opened jira issue.
Comments
Post a Comment