public class RabbitMQMessageSender extends Object implements org.reactivestreams.Processor<Message<?>,Message<?>>, org.reactivestreams.Subscription
Processor
and Subscription
that is responsible for sending
RabbitMQ messages to an external broker.Constructor and Description |
---|
RabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc,
io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Request the
Publisher 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 the
Publisher in response to requests to Subscription.request(long) . |
void |
onSubscribe(org.reactivestreams.Subscription subscription)
Invoked after calling
Publisher.subscribe(Subscriber) . |
void |
request(long l)
No events will be sent by a
Publisher until demand is signaled via this method. |
void |
subscribe(org.reactivestreams.Subscriber<? super Message<?>> subscriber)
Request
Publisher to start streaming data. |
public RabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc, io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender)
oc
- the configuration parameters for outgoing messagesretrieveSender
- the underlying Vert.x RabbitMQPublisher
public void subscribe(org.reactivestreams.Subscriber<? super Message<?>> subscriber)
Publisher
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 single Subscriber
.
A Subscriber
should only subscribe once to a single Publisher
.
If the Publisher
rejects the subscription attempt or otherwise fails it will
signal the error via Subscriber.onError(java.lang.Throwable)
.
subscribe
in interface org.reactivestreams.Publisher<Message<?>>
subscriber
- the Subscriber
that will consume signals from this Publisher
public void onSubscribe(org.reactivestreams.Subscription subscription)
Publisher.subscribe(Subscriber)
.
No data will start flowing until Subscription.request(long)
is invoked.
It is the responsibility of this Subscriber
instance to call Subscription.request(long)
whenever more
data is wanted.
The Publisher
will send notifications only in response to Subscription.request(long)
.
onSubscribe
in interface org.reactivestreams.Subscriber<Message<?>>
subscription
- Subscription
that allows requesting data via Subscription.request(long)
public void onNext(Message<?> message)
Publisher
in response to requests to Subscription.request(long)
.onNext
in interface org.reactivestreams.Subscriber<Message<?>>
message
- the element signaledpublic void onError(Throwable t)
No further events will be sent even if Subscription.request(long)
is invoked again.
onError
in interface org.reactivestreams.Subscriber<Message<?>>
t
- the throwable signaledpublic void onComplete()
No further events will be sent even if Subscription.request(long)
is invoked again.
onComplete
in interface org.reactivestreams.Subscriber<Message<?>>
public void request(long l)
Publisher
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 either Subscriber.onError(Throwable)
or Subscriber.onComplete()
.
Note that this method is expected to be called only once on a given sender.
request
in interface org.reactivestreams.Subscription
l
- the strictly positive number of elements to requests to the upstream Publisher
public void cancel()
Publisher
to stop sending data and clean up resources.
Data may still be sent to meet previously signalled demand after calling cancel.
cancel
in interface org.reactivestreams.Subscription
Copyright © 2018–2021 SmallRye. All rights reserved.