All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jaconi.spring.rabbitmq.retry.RetryMessagesException Maven / Gradle / Ivy

There is a newer version: 1.1.23
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy