Class KafkaCustomScope

java.lang.Object
io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>
io.micronaut.configuration.kafka.scope.KafkaCustomScope
All Implemented Interfaces:
io.micronaut.context.LifeCycle<io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>>, io.micronaut.context.scope.CustomScope<KafkaScope>, Closeable, AutoCloseable

@Singleton @Internal public final class KafkaCustomScope extends io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>
Stores KafkaScope beans for the duration of a Kafka listener invocation.
Since:
5.5.0
Author:
graemerocher
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Handle for an active Kafka scope.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    execute(Runnable action)
    Executes an action within a Kafka scope.
    <T> T
    execute(Supplier<T> action)
    Executes an action within a Kafka scope.
    protected @Nullable Map<@NonNull io.micronaut.inject.BeanIdentifier, @NonNull io.micronaut.context.scope.CreatedBean<@NonNull ?>>
    getScopeMap(boolean forCreation)
     
    boolean
     
    Activates the Kafka scope on the current thread.

    Methods inherited from class io.micronaut.context.scope.AbstractConcurrentCustomScope

    annotationType, destroyScope, doCreate, findBeanRegistration, getOrCreate, handleDestructionException, remove, stop

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.context.scope.CustomScope

    findBeanRegistration

    Methods inherited from interface io.micronaut.context.LifeCycle

    refresh, start
  • Constructor Details

    • KafkaCustomScope

      public KafkaCustomScope()
  • Method Details

    • open

      public KafkaCustomScope.Scope open()
      Activates the Kafka scope on the current thread.
      Returns:
      A handle that closes the current scope when the invocation ends
    • execute

      public <T> T execute(Supplier<T> action)
      Executes an action within a Kafka scope.
      Type Parameters:
      T - The result type
      Parameters:
      action - The action to execute
      Returns:
      The action result
    • execute

      public void execute(Runnable action)
      Executes an action within a Kafka scope.
      Parameters:
      action - The action to execute
    • isRunning

      public boolean isRunning()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface io.micronaut.context.LifeCycle<io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>>
      Specified by:
      close in class io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>
    • getScopeMap

      protected @Nullable Map<@NonNull io.micronaut.inject.BeanIdentifier, @NonNull io.micronaut.context.scope.CreatedBean<@NonNull ?>> getScopeMap(boolean forCreation)
      Specified by:
      getScopeMap in class io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>