Message Loss (message sent to spring-amqp doesn't get published to rabbitmq)

298 Views Asked by At

We are having a setup where we are using spring-amqp transacted channels to push our messages to RabbitMq. During a testing we found that messages were not even getting published from spring-amqp to rabbitmq; we suspect metricsCollector.basicPublish(this) in com.rabbitmq.client.impl.ChannelN failure(no exception is thrown). enter image description here

because we can see that RabbitUtils.commitIfNecessary(channel) in org.springframework.amqp.rabbit.core.RabbitTemplate is not getting called when there is an issue executing metricsCollector.basicPublish(this) for the same code flow.

We have taken TCP dumps and could see that message were written to stream/socket on rabbitmq, but since commit didn't happen due to an a probable amqp api failure the messages were not delivered to corresponding queues.

Jars Version Being used in the setup:-

  1. spring-amqp-2.2.1.RELEASE.jar,
  2. spring-rabbit-2.2.1.RELEASE.jar
  3. amqp-client-5.7.3.jar,
  4. metrics-core-3.0.2.jar

Is anyone facing the similar issue? Can someone please help.

---edit 1 (Setup) :- We are using same connection Factory for flows with parent transaction and flows not running with parent transactions

On further analyzing the issue , we found that isChannelLocallyTransacted is sometimes showing in-consistent behavior because ConnectionFactoryUtils.isChannelTransactional(channel, getConnectionFactory() is sometimes having a reference to transacted channel (returns true hence expression isChannelLocallyTransacted evaluates to false) due to which tx.commit never happens; so message gets lost before getting committed to RabbitMQ.

enter image description here

0

There are 0 best solutions below