Class RabbitMQBroker
java.lang.Object
com.saicone.delivery4j.Broker
com.saicone.delivery4j.broker.RabbitMQBroker
RabbitMQ broker implementation to send data using queue and consumer via exchange.
-
Constructor Summary
ConstructorsConstructorDescriptionRabbitMQBroker(@NotNull Connection connection, @NotNull String exchange) Constructs a rabbitmq broker with provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionThe current connection.static @NotNull RabbitMQBrokerof(@NotNull String host, int port, @NotNull String username, @NotNull String password, @NotNull String virtualHost, @NotNull String exchange) Create a rabbitmq broker with provided parameters.static @NotNull RabbitMQBrokerCreate a rabbitmq broker with provided parameters.static @NotNull RabbitMQBrokerCreate a rabbitmq broker with provided parameters.protected voidonClose()Method to run when broker closes.protected voidonStart()Method to run when broker startsprotected voidonSubscribe(@NotNull String... channels) Method to run when broker is being subscribed to new channels.protected voidonUnsubscribe(@NotNull String... channels) Method to run when broker is being unsubscribed from channels.voidSend byte data array to provided channel.voidsetReconnectionInterval(int time, @NotNull TimeUnit unit) Set the reconnection interval that will be used on this redis broker instance.Methods inherited from class Broker
clear, close, getConsumer, getExecutor, getLogger, getSubscribedChannels, isEnabled, receive, setConsumer, setEnabled, setExecutor, setLogger, start, subscribe, unsubscribe
-
Constructor Details
-
RabbitMQBroker
-
-
Method Details
-
of
-
of
-
of
@NotNull public static @NotNull RabbitMQBroker of(@NotNull @NotNull String host, int port, @NotNull @NotNull String username, @NotNull @NotNull String password, @NotNull @NotNull String virtualHost, @NotNull @NotNull String exchange) Create a rabbitmq broker with provided parameters.- Parameters:
host- the host to connect.port- the port host.username- the username to validate authentication.password- the password to validate authentication.virtualHost- the virtual host.exchange- the pre-channel to use.- Returns:
- a newly generated rabbitmq broker.
-
onStart
-
onClose
-
onSubscribe
-
onUnsubscribe
-
send
Description copied from class:BrokerSend byte data array to provided channel.- Specified by:
sendin classBroker- Parameters:
channel- the channel name.data- the data to send.- Throws:
IOException- if anny error occurs while sending the data.
-
setReconnectionInterval
-
getConnection
The current connection.- Returns:
- a rabbitmq connection object.
-