Class RabbitMQMessageSender
- java.lang.Object
-
- io.smallrye.reactive.messaging.rabbitmq.RabbitMQMessageSender
-
- All Implemented Interfaces:
org.reactivestreams.Processor<Message<?>,Message<?>>
,org.reactivestreams.Publisher<Message<?>>
,org.reactivestreams.Subscriber<Message<?>>
,org.reactivestreams.Subscription
public class RabbitMQMessageSender extends Object implements org.reactivestreams.Processor<Message<?>,Message<?>>, org.reactivestreams.Subscription
An implementation ofProcessor
andSubscription
that is responsible for sending RabbitMQ messages to an external broker.
-
-
Constructor Summary
Constructors Constructor Description RabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc, io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Request thePublisher
to stop sending data and clean up resources.void
onComplete()
Successful terminal state.void
onError(Throwable t)
Failed terminal state.void
onNext(Message<?> message)
Data notification sent by thePublisher
in response to requests toSubscription.request(long)
.void
onSubscribe(org.reactivestreams.Subscription subscription)
Invoked after callingPublisher.subscribe(Subscriber)
.void
request(long l)
No events will be sent by aPublisher
until demand is signaled via this method.void
subscribe(org.reactivestreams.Subscriber<? super Message<?>> subscriber)
RequestPublisher
to start streaming data.
-
-
-
Constructor Detail
-
RabbitMQMessageSender
public RabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc, io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender)
Constructor.- Parameters:
oc
- the configuration parameters for outgoing messagesretrieveSender
- the underlying Vert.xRabbitMQPublisher
-
-
Method Detail
-
subscribe
public void subscribe(org.reactivestreams.Subscriber<? super Message<?>> subscriber)
RequestPublisher
to start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
.Each
Subscription
will work for only a singleSubscriber
.A
Subscriber
should only subscribe once to a singlePublisher
.If the
Publisher
rejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(java.lang.Throwable)
.- Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<Message<?>>
- Parameters:
subscriber
- theSubscriber
that will consume signals from thisPublisher
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription)
Invoked after callingPublisher.subscribe(Subscriber)
.No data will start flowing until
Subscription.request(long)
is invoked.It is the responsibility of this
Subscriber
instance to callSubscription.request(long)
whenever more data is wanted.The
Publisher
will send notifications only in response toSubscription.request(long)
.- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<Message<?>>
- Parameters:
subscription
-Subscription
that allows requesting data viaSubscription.request(long)
-
onNext
public void onNext(Message<?> message)
Data notification sent by thePublisher
in response to requests toSubscription.request(long)
.- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<Message<?>>
- Parameters:
message
- the element signaled
-
onError
public void onError(Throwable t)
Failed terminal state.No further events will be sent even if
Subscription.request(long)
is invoked again.- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<Message<?>>
- Parameters:
t
- the throwable signaled
-
onComplete
public void onComplete()
Successful terminal state.No further events will be sent even if
Subscription.request(long)
is invoked again.- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<Message<?>>
-
request
public void request(long l)
No events will be sent by aPublisher
until demand is signaled via this method.It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the
Publisher
as "effectively unbounded".Whatever has been requested can be sent by the
Publisher
so only signal demand for what can be safely handled.A
Publisher
can send less than is requested if the stream ends but then must emit eitherSubscriber.onError(Throwable)
orSubscriber.onComplete()
.Note that this method is expected to be called only once on a given sender.
- Specified by:
request
in interfaceorg.reactivestreams.Subscription
- Parameters:
l
- the strictly positive number of elements to requests to the upstreamPublisher
-
cancel
public void cancel()
Request thePublisher
to stop sending data and clean up resources.Data may still be sent to meet previously signalled demand after calling cancel.
- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-
-