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 ofProcessorandSubscriptionthat 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 voidcancel()Request thePublisherto stop sending data and clean up resources.voidonComplete()Successful terminal state.voidonError(Throwable t)Failed terminal state.voidonNext(Message<?> message)Data notification sent by thePublisherin response to requests toSubscription.request(long).voidonSubscribe(org.reactivestreams.Subscription subscription)Invoked after callingPublisher.subscribe(Subscriber).voidrequest(long l)No events will be sent by aPublisheruntil demand is signaled via this method.voidsubscribe(org.reactivestreams.Subscriber<? super Message<?>> subscriber)RequestPublisherto 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)
RequestPublisherto start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription.Each
Subscriptionwill work for only a singleSubscriber.A
Subscribershould only subscribe once to a singlePublisher.If the
Publisherrejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(java.lang.Throwable).- Specified by:
subscribein interfaceorg.reactivestreams.Publisher<Message<?>>- Parameters:
subscriber- theSubscriberthat 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
Subscriberinstance to callSubscription.request(long)whenever more data is wanted.The
Publisherwill send notifications only in response toSubscription.request(long).- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<Message<?>>- Parameters:
subscription-Subscriptionthat allows requesting data viaSubscription.request(long)
-
onNext
public void onNext(Message<?> message)
Data notification sent by thePublisherin response to requests toSubscription.request(long).- Specified by:
onNextin 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:
onErrorin 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:
onCompletein interfaceorg.reactivestreams.Subscriber<Message<?>>
-
request
public void request(long l)
No events will be sent by aPublisheruntil 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
Publisheras "effectively unbounded".Whatever has been requested can be sent by the
Publisherso only signal demand for what can be safely handled.A
Publishercan 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:
requestin interfaceorg.reactivestreams.Subscription- Parameters:
l- the strictly positive number of elements to requests to the upstreamPublisher
-
cancel
public void cancel()
Request thePublisherto stop sending data and clean up resources.Data may still be sent to meet previously signalled demand after calling cancel.
- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-
-