Class MdcAwareConsumer<T>

java.lang.Object
org.forgerock.http.protocol.MdcAwareConsumer<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
io.reactivex.rxjava3.functions.Consumer<T>

public final class MdcAwareConsumer<T> extends Object implements io.reactivex.rxjava3.functions.Consumer<T>
An implementation of Consumer that will preserve the SLF4J MDC.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(T t)
     
    static <T> io.reactivex.rxjava3.functions.Consumer<T>
    mdcAwareConsumer(io.reactivex.rxjava3.functions.Consumer<T> delegate)
    Wraps the delegate Consumer with another Consumer instance that will capture the current MDC context, and will use it when delegating the calls to the delegated Consumer.
    static <T> io.reactivex.rxjava3.functions.Consumer<T>
    mdcAwareConsumer(Map<String,String> mdc, io.reactivex.rxjava3.functions.Consumer<T> delegate)
    Wraps the delegate Consumer with another Consumer instance that will use the provided MDC context when delegating the calls to the delegated Consumer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • accept

      public void accept(T t) throws Throwable
      Specified by:
      accept in interface io.reactivex.rxjava3.functions.Consumer<T>
      Throws:
      Throwable
    • mdcAwareConsumer

      public static <T> io.reactivex.rxjava3.functions.Consumer<T> mdcAwareConsumer(io.reactivex.rxjava3.functions.Consumer<T> delegate)
      Wraps the delegate Consumer with another Consumer instance that will capture the current MDC context, and will use it when delegating the calls to the delegated Consumer.
      Type Parameters:
      T - the value type.
      Parameters:
      delegate - the Subscriber to delegate the calls to
      Returns:
      A Consumer that will position the captured MDC context before each call.
      See Also:
    • mdcAwareConsumer

      public static <T> io.reactivex.rxjava3.functions.Consumer<T> mdcAwareConsumer(Map<String,String> mdc, io.reactivex.rxjava3.functions.Consumer<T> delegate)
      Wraps the delegate Consumer with another Consumer instance that will use the provided MDC context when delegating the calls to the delegated Consumer.
      Type Parameters:
      T - the value type.
      Parameters:
      mdc - The MDC to use when delegating the calls
      delegate - the Consumer to delegate the calls to
      Returns:
      A Consumer that will position the captured MDC context before each call.