Class MoveMessages
java.lang.Object
com.reallifedeveloper.tools.rabbitmq.MoveMessages
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 Summary
ConstructorsConstructorDescriptionMoveMessages
(com.rabbitmq.client.ConnectionFactory connectionFactory) Creates a newMoveMessages
instance that uses the givenConnectionFactory
to connect to RabbitMQ. -
Method Summary
Modifier and TypeMethodDescriptionstatic MoveMessages
createInstance
(String host, String username, String password, String virtualHost) Factory method that creates a newMoveMessages
object that connects to RabbitMQ on the given host and vhost, using the given username and password.void
moveAllMessagesToExchange
(String fromQueue, String toExchange) Moves all messages from a queue to an exchange.
-
Constructor Details
-
MoveMessages
public MoveMessages(com.rabbitmq.client.ConnectionFactory connectionFactory) Creates a newMoveMessages
instance that uses the givenConnectionFactory
to connect to RabbitMQ.- Parameters:
connectionFactory
- theConnectionFactory
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 newMoveMessages
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 runningusername
- the username to use for authenticationpassword
- the password to use for authenticationvirtualHost
- 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 messagestoExchange
- the exchange to which to send messages- Throws:
IOException
- if moving the messages failed because of an I/O problemTimeoutException
- if connecting to the broker timed out
-