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 ClassesModifier and TypeClassDescriptionstatic interfaceHandle for an active Kafka scope. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidExecutes an action within a Kafka scope.<T> TExecutes an action within a Kafka scope.protected @Nullable Map<@NonNull io.micronaut.inject.BeanIdentifier, @NonNull io.micronaut.context.scope.CreatedBean<@NonNull ?>> getScopeMap(boolean forCreation) booleanopen()Activates the Kafka scope on the current thread.Methods inherited from class io.micronaut.context.scope.AbstractConcurrentCustomScope
annotationType, destroyScope, doCreate, findBeanRegistration, getOrCreate, handleDestructionException, remove, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.scope.CustomScope
findBeanRegistrationMethods inherited from interface io.micronaut.context.LifeCycle
refresh, start
-
Constructor Details
-
KafkaCustomScope
public KafkaCustomScope()
-
-
Method Details
-
open
Activates the Kafka scope on the current thread.- Returns:
- A handle that closes the current scope when the invocation ends
-
execute
Executes an action within a Kafka scope.- Type Parameters:
T- The result type- Parameters:
action- The action to execute- Returns:
- The action result
-
execute
Executes an action within a Kafka scope.- Parameters:
action- The action to execute
-
isRunning
public boolean isRunning() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceio.micronaut.context.LifeCycle<io.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>>- Specified by:
closein classio.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:
getScopeMapin classio.micronaut.context.scope.AbstractConcurrentCustomScope<KafkaScope>
-