Package org.acemq.amqp.api
Interface MessageHandler<T>
- Type Parameters:
T- decoded payload type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Handles one message.
The outcome is expressed by returning or throwing, which keeps the common case free of ceremony:
- return normally to accept the message;
- throw
AceRetryableExceptionto send it to the next retry tier; - throw
AceFatalExceptionto dead-letter it without spending retries; - throw anything else and the configured error classifier decides, defaulting to retry.
Handlers that want to state the outcome directly should implement
AckAwareHandler instead.
A handler must never sleep in order to retry. Throw, and let RetryPolicy decide:
a short wait is held by the engine, which knows the attempt count and can put the message
back with it advanced, and a long one is handed to the broker so that a waiting message does
not hold a delivery slot at all. A sleep inside the handler does neither, and loses the
attempt count when the process restarts.
-
Method Summary
-
Method Details
-
handle
- Parameters:
message- the delivery to handle- Throws:
Exception- to signal failure; the type decides whether it is retried
-