Git Product home page Git Product logo

Comments (10)

artembilan avatar artembilan commented on April 27, 2024 1

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.

artembilan avatar artembilan commented on April 27, 2024 1

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.

artembilan avatar artembilan commented on April 27, 2024 1

Correct. We have it scheduled for February, 19th.

from spring-amqp.

artembilan avatar artembilan commented on April 27, 2024

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.

alexey-anufriev avatar alexey-anufriev commented on April 27, 2024

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.

artembilan avatar artembilan commented on April 27, 2024

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.

alexey-anufriev avatar alexey-anufriev commented on April 27, 2024

Thank you @artembilan for the explanation!

from spring-amqp.

alexey-anufriev avatar alexey-anufriev commented on April 27, 2024

@artembilan, one last question: how can I handle errors that happen in the post-processor but still within the listener method?

from spring-amqp.

alexey-anufriev avatar alexey-anufriev commented on April 27, 2024

@artembilan, thanks again for your help.

from spring-amqp.

alexey-anufriev avatar alexey-anufriev commented on April 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.