Comments (10)
Yeah...
I see your point:
if (this.afterReceivePostProcessors != null) {
for (MessagePostProcessor processor : this.afterReceivePostProcessors) {
message = processor.postProcessMessage(message);
if (message == null) {
throw new ImmediateAcknowledgeAmqpException(
"Message Post Processor returned 'null', discarding message");
}
}
}
This way it does not reach listener method yet.
We probably need to relax the mention logic in the commitIfNecessary()
and call this.channel.basicAck(deliveryTag, true);
independently of the ack mode...
Or make a soft change to call this ack here instead of deferring to the exception flow control.
Reopening as this sounds like valid request.
Thanks
from spring-amqp.
So, the fix is in.
Now SimpleMessageListenerContainer
has a new option enforceImmediateAckForManual
you can set to true
- and those ImmediateAcknowledgeAmqpException
will trigger and ack on the message even if AcknowledgeMode.MANUAL
.
Feel free to pull 3.1.2-SNAPSHOT
for testing on your side.
Thanks
from spring-amqp.
Correct. We have it scheduled for February, 19th.
from spring-amqp.
Apparently that doesn't work for container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
:
boolean ackRequired = !this.acknowledgeMode.isAutoAck() && !this.acknowledgeMode.isManual();
So, instead of throwing that exception from your @RabbitListener
, you have to do channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
.
Technically those are exactly the same, but since you are in a manual
mode, you cannot rely on auto-ack: just doesn't match according to the logic.
Closed as Works as Designed
from spring-amqp.
This scenario I shared is a simple version of the problem, but what if I want to immediate-ack from the Error Handler? For example, I have a custom Error Handler that has to map business exceptions into AQMP-ones. I have already successfully used AmqpRejectAndDontRequeueException
but now want to use ImmediateAcknowledgeAmqpException
there as well.
What should I do in this case?
from spring-amqp.
The MANUAL
ack mode means that you handle errors in your listener method.
The error handler on the listener is not aware of the Channel
.
from spring-amqp.
Thank you @artembilan for the explanation!
from spring-amqp.
@artembilan, one last question: how can I handle errors that happen in the post-processor but still within the listener method?
from spring-amqp.
@artembilan, thanks again for your help.
from spring-amqp.
@artembilan, thank you for your effort! I will take a look at the snapshot version. I hope this will be included in the next Spring Boot release (we usually bring it all together).
from spring-amqp.
Related Issues (20)
- MessageProperties setDelay maximum value problem HOT 3
- TraceId propagation to the new thread local HOT 4
- Wrong ClassLoader is used for message deserialization when devtools are active
- Wrong ClassLoader is used for message deserialization when devtools are active HOT 1
- Kotlin suspend functions return type is incorrect HOT 3
- Kotlin suspend functions return type is incorrect HOT 1
- Channel cache leak when no answers from broker for pending confirms
- Channel cache leak when no answers from broker for pending confirms HOT 1
- Invoke RabbitListenerErrorHandler when the batch of the listener is enabled HOT 2
- Document that micrometer observations aren't started for batch listeners HOT 4
- Unable to access AMQP Channel from RabbitListenerErrorHandler in case of MessageConversionException HOT 1
- Deadlock when reaching channel limit in DirectMessageListenerContainer HOT 5
- Remove deprecated method in the `RabbitListenerErrorHandler`
- DefaultMessagePropertiesConverter#toMessageProperties should handle x-delay in Short HOT 4
- DefaultMessagePropertiesConverter#toMessageProperties should handle x-delay in Short HOT 1
- Memory leak with AsyncRabbitTemplate HOT 5
- Memory leak with AsyncRabbitTemplate HOT 1
- Use JDK `ObjectInputFilter` instead of calling `AllowedListDeserializingMessageConverter::checkAllowedList` in `ConfigurableObjectInputStream::resolveClass` HOT 1
- Fix RabbitMQ x-death header documentation HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp.