Package io.micronaut.context.event
Interface ApplicationEventPublisher<T>
-
- Type Parameters:
T- The event type
- All Known Subinterfaces:
ApplicationContext,BeanContext,InitializableBeanContext
- All Known Implementing Classes:
DefaultApplicationContext,DefaultBeanContext
public interface ApplicationEventPublisher<T>Interface for classes that publish events received by
ApplicationEventListenerinstances.Note that this interface is designed for application level, non-blocking synchronous events for decoupling code and is not a replacement for a messaging system
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static ApplicationEventPublisher<?>NO_OP
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <K> ApplicationEventPublisher<K>noOp()Returns a no-op instance ofApplicationEventPublisher.voidpublishEvent(T event)Publish the given event.default java.util.concurrent.Future<java.lang.Void>publishEventAsync(T event)Publish the given event.
-
-
-
Field Detail
-
NO_OP
static final ApplicationEventPublisher<?> NO_OP
-
-
Method Detail
-
noOp
static <K> ApplicationEventPublisher<K> noOp()
Returns a no-op instance ofApplicationEventPublisher.- Type Parameters:
K- The event type- Returns:
- an instance of
ApplicationEventPublisher
-
publishEvent
void publishEvent(@NonNull T event)Publish the given event. The event will be published synchronously and only return once all listeners have consumed the event.- Parameters:
event- The event to publish
-
publishEventAsync
@NonNull default java.util.concurrent.Future<java.lang.Void> publishEventAsync(@NonNull T event)Publish the given event. The event will be published asynchronously. A future is returned that can be used to check whether the event completed successfully or not.- Parameters:
event- The event to publish- Returns:
- A future that completes when the event is published
- Since:
- 1.3.5
-
-