Package com.kamikazejam.kamicommon.amqp
Class RabbitMQAPI
java.lang.Object
com.kamikazejam.kamicommon.amqp.RabbitMQAPI
-
Method Summary
Modifier and TypeMethodDescriptionvoidbasicAck(long deliveryTag, boolean multiple) Acknowledge a message by its delivery tag SeeChannel.basicAck(long, boolean)voiddeclareQueue(@NotNull String queueName) Declares a queue with a default TTL of 60 seconds (iff not declared already)voiddeclareQueue(@NotNull String queueName, boolean durable, boolean exclusive, boolean autoDelete, @Nullable Long TTL_MS) Declares a queue with a specified TTL (iff not declared already)voiddeclareQueue(@NotNull String queueName, @Nullable Long TTL_MS) Declares a queue with a specified TTL (iff not declared already)@NotNull com.rabbitmq.client.ChannelGet the underlying RabbitMQChannelfor direct accessvoidpublishFanout(@NotNull String exchangeName, com.rabbitmq.client.AMQP.BasicProperties props, @NotNull String message) Publish a message to a queue (with properties) - does NOT listen for a responsevoidpublishFanout(@NotNull String exchangeName, @NotNull String message) Publish a message to a queue - does NOT listen for a responsevoidpublishMessage(@NotNull String queueName, com.rabbitmq.client.AMQP.BasicProperties props, @NotNull String message) Publish a message to a queue (with properties) - does NOT listen for a responsevoidpublishMessage(@NotNull String queueName, @NotNull String message) Publish a message to a queue - does NOT listen for a response@NotNull CompletableFuture<String> publishRPC(@NotNull RabbitRpcQueue queue, @NotNull String message) Publish a 'RPC' style message and wait for a responsevoidregisterFanConsumer(@NotNull String queueName, @NotNull String exchange, @NotNull RabbitServerCallback callback) Register a standard consumer (default to auto-acknowledgement)voidregisterFanConsumer(@NotNull String queueName, @NotNull String exchange, @NotNull RabbitServerCallback callback, boolean autoAck) Register a standard consumervoidregisterRpcConsumer(@NotNull RabbitRpcQueue queue, @NotNull RabbitRpcCallback callback) Register a 'RPC' style consumer to listen for requestsvoidregisterStdConsumer(@NotNull String queueName, @NotNull RabbitServerCallback callback) Register a standard consumer (default to auto-acknowledgement)voidregisterStdConsumer(@NotNull String queueName, @NotNull RabbitServerCallback callback, boolean autoAck) Register a standard consumervoidstop()Stops the internal RabbitMQ Connection and Channel This API remains usable, but other methods may incur additional delays as the connection is re-established
-
Method Details
-
stop
public void stop()Stops the internal RabbitMQ Connection and Channel This API remains usable, but other methods may incur additional delays as the connection is re-established -
basicAck
public void basicAck(long deliveryTag, boolean multiple) Acknowledge a message by its delivery tag SeeChannel.basicAck(long, boolean) -
publishMessage
Publish a message to a queue - does NOT listen for a response- Parameters:
queueName- the name of the queuemessage- the message to publish
-
publishMessage
public void publishMessage(@NotNull @NotNull String queueName, @NotNull com.rabbitmq.client.AMQP.BasicProperties props, @NotNull @NotNull String message) Publish a message to a queue (with properties) - does NOT listen for a response- Parameters:
queueName- the name of the queueprops- additional message propertiesmessage- the message to publish
-
registerStdConsumer
public void registerStdConsumer(@NotNull @NotNull String queueName, @NotNull @NotNull RabbitServerCallback callback) Register a standard consumer (default to auto-acknowledgement)- Parameters:
queueName- the name of the queuecallback- the callback to consume messages
-
registerStdConsumer
public void registerStdConsumer(@NotNull @NotNull String queueName, @NotNull @NotNull RabbitServerCallback callback, boolean autoAck) Register a standard consumer- Parameters:
queueName- the name of the queuecallback- the callback to consume messagesautoAck- if messages should be auto-acknowledged
-
publishRPC
@NotNull public @NotNull CompletableFuture<String> publishRPC(@NotNull @NotNull RabbitRpcQueue queue, @NotNull @NotNull String message) Publish a 'RPC' style message and wait for a response- Parameters:
queue- The MQRpcQueue for client-server communicationmessage- The message to publish- Returns:
- a CompletableFuture which will be completed when the response is received
-
registerRpcConsumer
public void registerRpcConsumer(@NotNull @NotNull RabbitRpcQueue queue, @NotNull @NotNull RabbitRpcCallback callback) Register a 'RPC' style consumer to listen for requests- Parameters:
queue- The MQRpcQueue for client-server communicationcallback- The callback to consume messages
-
registerFanConsumer
public void registerFanConsumer(@NotNull @NotNull String queueName, @NotNull @NotNull String exchange, @NotNull @NotNull RabbitServerCallback callback) Register a standard consumer (default to auto-acknowledgement)- Parameters:
queueName- the name of the queueexchange- the callback to consume messagescallback- the callback to consume messages
-
registerFanConsumer
public void registerFanConsumer(@NotNull @NotNull String queueName, @NotNull @NotNull String exchange, @NotNull @NotNull RabbitServerCallback callback, boolean autoAck) Register a standard consumer- Parameters:
queueName- the name of the queuecallback- the callback to consume messagesautoAck- if messages should be auto-acknowledged
-
publishFanout
Publish a message to a queue - does NOT listen for a response- Parameters:
exchangeName- the name of the exchange to publish tomessage- the message to publish
-
publishFanout
public void publishFanout(@NotNull @NotNull String exchangeName, @NotNull com.rabbitmq.client.AMQP.BasicProperties props, @NotNull @NotNull String message) Publish a message to a queue (with properties) - does NOT listen for a response- Parameters:
exchangeName- the name of the queueprops- additional message propertiesmessage- the message to publish
-
declareQueue
Declares a queue with a default TTL of 60 seconds (iff not declared already)- Parameters:
queueName- the name of the queue to declare
-
declareQueue
Declares a queue with a specified TTL (iff not declared already)- Parameters:
queueName- the name of the queue to declareTTL_MS- the time-to-live of the queue (in milliseconds)
-
declareQueue
public void declareQueue(@NotNull @NotNull String queueName, boolean durable, boolean exclusive, boolean autoDelete, @Nullable @Nullable Long TTL_MS) Declares a queue with a specified TTL (iff not declared already)- Parameters:
queueName- the name of the queue to declaredurable- whether the queue should survive a broker restartexclusive- whether the queue should be exclusive to the connectionautoDelete- whether the queue should be auto-deleted when no longer in useTTL_MS- the time-to-live of the queue (in milliseconds)
-
getChannel
@Internal @NotNull public @NotNull com.rabbitmq.client.Channel getChannel()Get the underlying RabbitMQChannelfor direct access
-