Interface MultiInterceptor

  • All Superinterfaces:
    MutinyInterceptor

    public interface MultiInterceptor
    extends MutinyInterceptor
    Allow being notified when a new Multi instance is created and when this Multi receives events.

    Implementations are expected to be exposed as SPI, and so the implementation class must be declared in the META-INF/services/io.smallrye.mutiny.infrastructure.MultiInterceptor file.

    • Method Detail

      • onMultiCreation

        default <T> Multi<T> onMultiCreation​(Multi<T> multi)
        Method called when a new instance of Multi is created. If can return a new Multi, or the passed Multi (default behavior) if the interceptor is not interested by this Multi.

        One use case for this method is the capture of a context at creation time (when the method is called) and restored when a subscriber subscribed to the produced multi. It is recommended to extend AbstractMulti to produce a new Multi instance.

        Type Parameters:
        T - the type of item produced by the multi
        Parameters:
        multi - the created multi
        Returns:
        the passed multi or a new instance, must not be null
      • onSubscription

        default <T> org.reactivestreams.Subscriber<? super T> onSubscription​(org.reactivestreams.Publisher<? extends T> instance,
                                                                             org.reactivestreams.Subscriber<? super T> subscriber)
        Method called when a subscriber subscribes to a Multi. This method lets you substitute the subscriber.
        Type Parameters:
        T - the type of item
        Parameters:
        instance - the instance of publisher
        subscriber - the subscriber
        Returns:
        the subscriber to use instead of the passed one. By default, it returns the given subscriber.