Class RabbitMQPublisher
- java.lang.Object
-
- io.vertx.mutiny.rabbitmq.RabbitMQPublisher
-
public class RabbitMQPublisher extends Object
A reliable publisher that- Queues up messages internally until it can successfully call basicPublish.
- Notifies the caller using a robust ID (not delivery tag) when the message is confirmed by rabbit.
original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<RabbitMQPublisher>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description RabbitMQPublisher(io.vertx.rabbitmq.RabbitMQPublisher delegate)
RabbitMQPublisher(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RabbitMQPublisher
create(Vertx vertx, RabbitMQClient client, io.vertx.rabbitmq.RabbitMQPublisherOptions options)
boolean
equals(Object o)
ReadStream<io.vertx.rabbitmq.RabbitMQPublisherConfirmation>
getConfirmationStream()
io.vertx.rabbitmq.RabbitMQPublisher
getDelegate()
int
hashCode()
static RabbitMQPublisher
newInstance(io.vertx.rabbitmq.RabbitMQPublisher arg)
io.smallrye.mutiny.Uni<Void>
publish(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Publish a message.Void
publishAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Blocking variant ofpublish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
.void
publishAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Variant ofpublish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.io.smallrye.mutiny.Uni<Long>
publishConfirm(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Publish a message and complete when publish confirm has returned.Long
publishConfirmAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Blocking variant ofpublishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
.void
publishConfirmAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Variant ofpublishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.int
queueSize()
void
restart()
io.smallrye.mutiny.Uni<Void>
start()
Start the rabbitMQ publisher.Void
startAndAwait()
Blocking variant ofstart()
.void
startAndForget()
Variant ofstart()
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
stop()
Stop the rabbitMQ publisher.Void
stopAndAwait()
Blocking variant ofstop()
.void
stopAndForget()
Variant ofstop()
that ignores the result of the operation.String
toString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<RabbitMQPublisher> __TYPE_ARG
-
-
Constructor Detail
-
RabbitMQPublisher
public RabbitMQPublisher(io.vertx.rabbitmq.RabbitMQPublisher delegate)
-
RabbitMQPublisher
public RabbitMQPublisher(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.rabbitmq.RabbitMQPublisher getDelegate()
-
create
public static RabbitMQPublisher create(Vertx vertx, RabbitMQClient client, io.vertx.rabbitmq.RabbitMQPublisherOptions options)
- Parameters:
vertx
- the vertx instance.client
- the RabbitMQClient.options
- options for the publisher.- Returns:
- the publisher
-
start
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> start()
Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
startAndAwait
public Void startAndAwait()
Blocking variant ofstart()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
startAndForget
public void startAndForget()
-
stop
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> stop()
Stop the rabbitMQ publisher. Calling this is optional, but it gives the opportunity to drain the send queue without losing messages. Future calls to publish will be ignored.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
stopAndAwait
public Void stopAndAwait()
Blocking variant ofstop()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
stopAndForget
public void stopAndForget()
-
restart
public void restart()
-
getConfirmationStream
public ReadStream<io.vertx.rabbitmq.RabbitMQPublisherConfirmation> getConfirmationStream()
- Returns:
- the ReadStream that contains the message IDs for confirmed messages.
-
queueSize
public int queueSize()
- Returns:
- the number of published, but not sent, messages.
-
publish
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> publish(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Publish a message.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
exchange
-routingKey
-properties
-body
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
publishAndAwait
public Void publishAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Blocking variant ofpublish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
exchange
-routingKey
-properties
-body
-- Returns:
- the Void instance produced by the operation.
-
publishAndForget
public void publishAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Variant ofpublish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
publish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompublish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Parameters:
exchange
-routingKey
-properties
-body
-
-
publishConfirm
@CheckReturnValue public io.smallrye.mutiny.Uni<Long> publishConfirm(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Publish a message and complete when publish confirm has returned.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
exchange
-routingKey
-properties
-body
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
publishConfirmAndAwait
public Long publishConfirmAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Blocking variant ofpublishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
exchange
-routingKey
-properties
-body
-- Returns:
- the Long instance produced by the operation.
-
publishConfirmAndForget
public void publishConfirmAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
Variant ofpublishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
publishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompublishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Parameters:
exchange
-routingKey
-properties
-body
-
-
newInstance
public static RabbitMQPublisher newInstance(io.vertx.rabbitmq.RabbitMQPublisher arg)
-
-