-
Notifications
You must be signed in to change notification settings - Fork 585
Channel Closing #1074
-
Describe the bug
Hello Guys.
I'm using Apache Camel and RabbitMq on a project to make an update in some itens status, if the item doesn't exists in database i need to purge the message. After pass and return by Router of Apache when channel.basicAck()
is called throws an exception,. Follow the snippets
public void readMessage(@Payload final String payload, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag
) throws IOException {
try {
final var myObject = objectMapper.readValue(payload, myObject.class);
log.info("Object received : {}", myObject );
service.paymentObject(myObject);
channel.basicAck(tag, false);
Exception: org.springframework.amqp.AmqpApplicationContextClosedException: The ApplicationContext is closed and the ConnectionFactory can no longer create connections.
How can I fix that?
Specs:
Spring: 2.2.0
JDK 11 - Oracle OpenJDK version 11.0.6
Camel: 3.0.1
Reproduction steps
- Receive the message in Listener
- Go to Router (Apache Camel), try to verify if value exists in other components
- If the value doens't exists purge the message of queue (Now its throwing exception)
...
Expected behavior
To Handle the exception and purge the invalid messages of queue
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
We cannot suggest much without server logs. I'm afraid our team won't be setting up Apache Camel to reproduce and troubleshoot this. You can put together an executable example in a repo but logs and a traffic will likely be enough.
My best guess right now is that you try to ack on a channel that's different from the channel on which you have received the delivery. That results in a channel exception. Whether that can result in an "application context closure" in Spring AMQP, I don't know, but doing so will result in a channel exception that renders the channel unusable.
Double acking or acking when the consumer was set up to use automatic acknowledgement would have the same effect.
Beta Was this translation helpful? Give feedback.