public class RabbitMQClient extends Object
| Constructor and Description |
|---|
RabbitMQClient(String uri)
Builds a new instance of
RabbitMQClient |
RabbitMQClient(String serverHost,
int serverPort,
String serverVirtualHost,
String serverUsername,
String serverPassword)
Builds a new instance of
RabbitMQClient |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(String exchangeName,
String exchangeOptions,
String queueName,
String queueOptions,
String bindingKey,
String bindingArguments)
Creates a relationship between an exchange and a queue.
|
void |
close()
Closes the channel and the connection with the server.
|
void |
openChannel()
Opens a new channel into the opened connection.
|
void |
publish(String exchangeName,
String routingKey,
RabbitMQMessage message)
Publishes a new message over an exchange.
|
public RabbitMQClient(String serverHost, int serverPort, String serverVirtualHost, String serverUsername, String serverPassword) throws IOException
RabbitMQClientserverHost - The server host.serverPort - The server port.serverVirtualHost - The virtual host into the RabbitMQ server.serverUsername - The username to access the server.serverPassword - The password to access the server.IOException - It is thrown if there is some issue during the connection creation.public RabbitMQClient(String uri) throws IOException
RabbitMQClienturi - The connection parameters in the form amqp://userName:password@hostName:portNumber/virtualHostIOException - It is thrown if there is some issue during the connection creation.public void openChannel()
throws IOException
IOException - It is thrown if there is some issue during the channel creation.public void bind(String exchangeName, String exchangeOptions, String queueName, String queueOptions, String bindingKey, String bindingArguments) throws IOException
exchangeName - The exchange's name.exchangeOptions - Options used when the exchange is created.
queueName - The queue's name.queueOptions - Options used when the queue is created.
bindingKey - The routine key to use for the binding.bindingArguments - This parameter is only used when the exchange's type is headers. In other cases is ignored.
IOException - If there is some issue creating the relationship.public void publish(String exchangeName, String routingKey, RabbitMQMessage message) throws IOException
exchangeName - The exchange's name where the message will be published.routingKey - The routing key used to route the message in the exchange.message - The message itself.IOException - If there is some issue publishing the message.public void close()
throws IOException
IOException - If there is some issue trying to close the channel or connection.Copyright © 2021 The Apache Software Foundation