Class 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 of Processor and Subscription that is responsible for sending RabbitMQ messages to an external broker.
    • 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 messages
        retrieveSender - the underlying Vert.x RabbitMQPublisher
    • Method Detail

      • subscribe

        public void subscribe​(org.reactivestreams.Subscriber<? super Message<?>> subscriber)
        Request 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).

        Specified by:
        subscribe in interface org.reactivestreams.Publisher<Message<?>>
        Parameters:
        subscriber - the Subscriber that will consume signals from this Publisher
      • onSubscribe

        public void onSubscribe​(org.reactivestreams.Subscription subscription)
        Invoked after calling 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).

        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<Message<?>>
        Parameters:
        subscription - Subscription that allows requesting data via Subscription.request(long)
      • onNext

        public void onNext​(Message<?> message)
        Data notification sent by the Publisher in response to requests to Subscription.request(long).
        Specified by:
        onNext in interface org.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 interface org.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 interface org.reactivestreams.Subscriber<Message<?>>
      • request

        public void request​(long l)
        No events will be sent by a 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.

        Specified by:
        request in interface org.reactivestreams.Subscription
        Parameters:
        l - the strictly positive number of elements to requests to the upstream Publisher
      • cancel

        public void cancel()
        Request the Publisher 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 interface org.reactivestreams.Subscription