public class RepublishMessageRecoverer extends Object implements MessageRecoverer
MessageRecoverer
implementation that republishes recovered messages
to a specified exchange with the exception stack trace stored in the
message header x-exception.
If no routing key is provided, the original routing key for the message,
prefixed with setErrorRoutingKeyPrefix(String)
(default "error.")
will be used to publish the message to the exchange provided in
name, or the template's default exchange if none is set.
Constructor and Description |
---|
RepublishMessageRecoverer(AmqpTemplate errorTemplate) |
RepublishMessageRecoverer(AmqpTemplate errorTemplate,
String errorExchange) |
RepublishMessageRecoverer(AmqpTemplate errorTemplate,
String errorExchange,
String errorRoutingKey) |
Modifier and Type | Method and Description |
---|---|
RepublishMessageRecoverer |
errorRoutingKeyPrefix(String errorRoutingKeyPrefix)
Apply a prefix to the outbound routing key, which will be prefixed to the original message
routing key (if no explicit routing key was provided in the constructor; ignored otherwise.
|
void |
recover(Message message,
Throwable cause)
Callback for message that was consumed but failed all retry attempts.
|
void |
setErrorRoutingKeyPrefix(String errorRoutingKeyPrefix) |
public RepublishMessageRecoverer(AmqpTemplate errorTemplate)
public RepublishMessageRecoverer(AmqpTemplate errorTemplate, String errorExchange)
public RepublishMessageRecoverer(AmqpTemplate errorTemplate, String errorExchange, String errorRoutingKey)
public RepublishMessageRecoverer errorRoutingKeyPrefix(String errorRoutingKeyPrefix)
errorRoutingKeyPrefix
- The prefix (default "error.").public void setErrorRoutingKeyPrefix(String errorRoutingKeyPrefix)
errorRoutingKeyPrefix
- The prefix (default "error.").errorRoutingKeyPrefix(String)
public void recover(Message message, Throwable cause)
MessageRecoverer
recover
in interface MessageRecoverer
message
- the message to recovercause
- the cause of the error