io.jaconi.spring.rabbitmq.retry.RetryMessagesException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-rabbitmq-retry Show documentation
Show all versions of spring-rabbitmq-retry Show documentation
Retries and exponential backoff for Spring AMQP.
package io.jaconi.spring.rabbitmq.retry;
import org.springframework.amqp.support.converter.MessagingMessageConverter;
import org.springframework.messaging.Message;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
public class RetryMessagesException extends RuntimeException {
private static final MessagingMessageConverter CONVERTER = new MessagingMessageConverter();
private final Collection> messages;
public RetryMessagesException(Message message) {
this(Collections.singleton(message));
}
@SuppressWarnings("unchecked")
public RetryMessagesException(org.springframework.amqp.core.Message message) {
this((Message) CONVERTER.fromMessage(message));
}
public RetryMessagesException(String message, Message message1) {
this(message, Collections.singleton(message1));
}
@SuppressWarnings("unchecked")
public RetryMessagesException(String message, org.springframework.amqp.core.Message message1) {
this(message, (Message) CONVERTER.fromMessage(message1));
}
public RetryMessagesException(Throwable cause, Message message) {
this(cause, Collections.singleton(message));
}
@SuppressWarnings("unchecked")
public RetryMessagesException(Throwable cause, org.springframework.amqp.core.Message message) {
this(cause, (Message) CONVERTER.fromMessage(message));
}
public RetryMessagesException(String message, Throwable cause, Message message1) {
this(message, cause, Collections.singleton(message1));
}
@SuppressWarnings("unchecked")
public RetryMessagesException(String message, Throwable cause, org.springframework.amqp.core.Message message1) {
this(message, cause, (Message) CONVERTER.fromMessage(message1));
}
public RetryMessagesException(Collection> messages) {
super("retrying %d erroneous messages".formatted(messages.size()));
this.messages = new ArrayList<>();
this.messages.addAll(messages);
}
public RetryMessagesException(String message, Collection> messages) {
super(message);
this.messages = new ArrayList<>();
this.messages.addAll(messages);
}
public RetryMessagesException(Throwable cause, Collection> messages) {
super("retrying %d erroneous messages".formatted(messages.size()), cause);
this.messages = new ArrayList<>();
this.messages.addAll(messages);
}
public RetryMessagesException(String message, Throwable cause, Collection> messages) {
super(message, cause);
this.messages = new ArrayList<>();
this.messages.addAll(messages);
}
public Collection> getMessages() {
return messages;
}
}