Class QueryCorrelationId


  • public class QueryCorrelationId
    extends java.lang.Object
    (Optional) mechanism for query implementations to pick up a correlation id from the caller, to use in logging and error messages. Used by akka-projections to make correlating projection logs with debug and trace logging from the underlying akka persistence query implementations possible.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T callWithCorrelationId​(java.lang.String correlationId, java.util.function.Supplier<T> function)
      Java API: Expected to be used "around" calls to plugin query method, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      static <T> T callWithCorrelationId​(java.util.Optional<java.lang.String> correlationId, java.util.function.Supplier<T> function)
      Java API: Expected to be used "around" calls to plugin query method to pass along a previously extracted optional correlation id, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      static scala.Option<java.lang.String> get()
      Scala API: Expected to be called by query plugins directly after receiving a query call, before starting any asynchronous tasks.
      static java.util.Optional<java.lang.String> getCorrelationId()
      Java API: Expected to be called by query plugins directly after receiving a query call, before starting any asynchronous tasks.
      static <T> T withCorrelationId​(java.lang.String correlationId, scala.Function0<T> f)
      Scala API: Expected to be used "around" calls to plugin query method, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      static <T> T withCorrelationId​(scala.Option<java.lang.String> correlationId, scala.Function0<T> f)
      Scala API: Expected to be used "around" calls to plugin query method to pass along a previously extracted optional correlation id, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryCorrelationId

        public QueryCorrelationId()
    • Method Detail

      • withCorrelationId

        public static <T> T withCorrelationId​(java.lang.String correlationId,
                                              scala.Function0<T> f)
        Scala API: Expected to be used "around" calls to plugin query method, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      • withCorrelationId

        public static <T> T withCorrelationId​(scala.Option<java.lang.String> correlationId,
                                              scala.Function0<T> f)
        Scala API: Expected to be used "around" calls to plugin query method to pass along a previously extracted optional correlation id, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      • get

        public static scala.Option<java.lang.String> get()
        Scala API: Expected to be called by query plugins directly after receiving a query call, before starting any asynchronous tasks. Calling code is responsible to clear it out after method returns. The value is stored in a thread local so is not available across threads or streams. Further passing around of the uuid inside the query plugin implementation is up to the implementer.
      • callWithCorrelationId

        public static <T> T callWithCorrelationId​(java.util.Optional<java.lang.String> correlationId,
                                                  java.util.function.Supplier<T> function)
        Java API: Expected to be used "around" calls to plugin query method to pass along a previously extracted optional correlation id, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      • callWithCorrelationId

        public static <T> T callWithCorrelationId​(java.lang.String correlationId,
                                                  java.util.function.Supplier<T> function)
        Java API: Expected to be used "around" calls to plugin query method, will clear the correlation id from thread local to make sure there is no leak between logic executed on shared threads.
      • getCorrelationId

        public static java.util.Optional<java.lang.String> getCorrelationId()
        Java API: Expected to be called by query plugins directly after receiving a query call, before starting any asynchronous tasks. Calling code is responsible to clear it out after method returns. The value is stored in a thread local so is not available across threads or streams. Further passing around of the uuid inside the query plugin implementation is up to the implementer.