Class RabbitMQMessageSender
- All Implemented Interfaces:
Flow.Processor<org.eclipse.microprofile.reactive.messaging.Message<?>,,org.eclipse.microprofile.reactive.messaging.Message<?>> Flow.Publisher<org.eclipse.microprofile.reactive.messaging.Message<?>>,Flow.Subscriber<org.eclipse.microprofile.reactive.messaging.Message<?>>,Flow.Subscription
Flow.Processor and Flow.Subscription that is responsible for sending
RabbitMQ messages to an external broker.-
Constructor Summary
ConstructorsConstructorDescriptionRabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc, io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender, jakarta.enterprise.inject.Instance<io.opentelemetry.api.OpenTelemetry> openTelemetryInstance) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Request theFlow.Publisherto stop sending data and clean up resources.voidSuccessful terminal state.voidFailed terminal state.voidonNext(org.eclipse.microprofile.reactive.messaging.Message<?> message) Data notification sent by theFlow.Publisherin response to requests toFlow.Subscription.request(long).voidonSubscribe(Flow.Subscription subscription) Invoked after callingFlow.Publisher.subscribe(Subscriber).voidrequest(long l) No events will be sent by aFlow.Publisheruntil demand is signaled via this method.voidsubscribe(Flow.Subscriber<? super org.eclipse.microprofile.reactive.messaging.Message<?>> subscriber) RequestFlow.Publisherto start streaming data.
-
Constructor Details
-
RabbitMQMessageSender
public RabbitMQMessageSender(RabbitMQConnectorOutgoingConfiguration oc, io.smallrye.mutiny.Uni<io.vertx.mutiny.rabbitmq.RabbitMQPublisher> retrieveSender, jakarta.enterprise.inject.Instance<io.opentelemetry.api.OpenTelemetry> openTelemetryInstance) Constructor.- Parameters:
oc- the configuration parameters for outgoing messagesretrieveSender- the underlying Vert.xRabbitMQPublisher
-
-
Method Details
-
subscribe
public void subscribe(Flow.Subscriber<? super org.eclipse.microprofile.reactive.messaging.Message<?>> subscriber) RequestFlow.Publisherto start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Flow.Subscription.Each
Flow.Subscriptionwill work for only a singleFlow.Subscriber.A
Flow.Subscribershould only subscribe once to a singleFlow.Publisher.If the
Flow.Publisherrejects the subscription attempt or otherwise fails it will signal the error viaFlow.Subscriber.onError(java.lang.Throwable).- Specified by:
subscribein interfaceFlow.Publisher<org.eclipse.microprofile.reactive.messaging.Message<?>>- Parameters:
subscriber- theFlow.Subscriberthat will consume signals from thisFlow.Publisher
-
onSubscribe
Invoked after callingFlow.Publisher.subscribe(Subscriber).No data will start flowing until
Flow.Subscription.request(long)is invoked.It is the responsibility of this
Flow.Subscriberinstance to callFlow.Subscription.request(long)whenever more data is wanted.The
Flow.Publisherwill send notifications only in response toFlow.Subscription.request(long).- Specified by:
onSubscribein interfaceFlow.Subscriber<org.eclipse.microprofile.reactive.messaging.Message<?>>- Parameters:
subscription-Flow.Subscriptionthat allows requesting data viaFlow.Subscription.request(long)
-
onNext
public void onNext(org.eclipse.microprofile.reactive.messaging.Message<?> message) Data notification sent by theFlow.Publisherin response to requests toFlow.Subscription.request(long).- Specified by:
onNextin interfaceFlow.Subscriber<org.eclipse.microprofile.reactive.messaging.Message<?>>- Parameters:
message- the element signaled
-
onError
Failed terminal state.No further events will be sent even if
Flow.Subscription.request(long)is invoked again.- Specified by:
onErrorin interfaceFlow.Subscriber<org.eclipse.microprofile.reactive.messaging.Message<?>>- Parameters:
t- the throwable signaled
-
onComplete
public void onComplete()Successful terminal state.No further events will be sent even if
Flow.Subscription.request(long)is invoked again.- Specified by:
onCompletein interfaceFlow.Subscriber<org.eclipse.microprofile.reactive.messaging.Message<?>>
-
request
public void request(long l) No events will be sent by aFlow.Publisheruntil 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
Flow.Publisheras "effectively unbounded".Whatever has been requested can be sent by the
Flow.Publisherso only signal demand for what can be safely handled.A
Flow.Publishercan send less than is requested if the stream ends but then must emit eitherFlow.Subscriber.onError(Throwable)orFlow.Subscriber.onComplete().Note that this method is expected to be called only once on a given sender.
- Specified by:
requestin interfaceFlow.Subscription- Parameters:
l- the strictly positive number of elements to requests to the upstreamFlow.Publisher
-
cancel
public void cancel()Request theFlow.Publisherto stop sending data and clean up resources.Data may still be sent to meet previously signalled demand after calling cancel.
- Specified by:
cancelin interfaceFlow.Subscription
-