Class MoveMessages

java.lang.Object
com.reallifedeveloper.tools.rabbitmq.MoveMessages

public final class MoveMessages extends Object
Moves messages from a queue, e.g., a DLQ, to an exchange. This can be useful for redelivering messages that have been dead-lettered.
Author:
RealLifeDeveloper
  • Constructor Details

    • MoveMessages

      public MoveMessages(com.rabbitmq.client.ConnectionFactory connectionFactory)
      Creates a new MoveMessages instance that uses the given ConnectionFactory to connect to RabbitMQ.
      Parameters:
      connectionFactory - the ConnectionFactory to use to connect to Rabb8itMQ
  • Method Details

    • createInstance

      public static MoveMessages createInstance(String host, String username, String password, String virtualHost)
      Factory method that creates a new MoveMessages object that connects to RabbitMQ on the given host and vhost, using the given username and password.
      Parameters:
      host - the name of the host on which RabbitMQ is running
      username - the username to use for authentication
      password - the password to use for authentication
      virtualHost - the vhost to connect to
      Returns:
      the new MoveMessages instance
    • moveAllMessagesToExchange

      public void moveAllMessagesToExchange(String fromQueue, String toExchange) throws IOException, TimeoutException
      Moves all messages from a queue to an exchange.
      Parameters:
      fromQueue - the queue from which to read messages
      toExchange - the exchange to which to send messages
      Throws:
      IOException - if moving the messages failed because of an I/O problem
      TimeoutException - if connecting to the broker timed out