Oracle Logo

Asynchronous Events - CDI 2.0

 

CDI 2.0 Asynchronous Events Introduction

This facility allows beans to interact in a decoupled fashion, with no compile-time dependencies between the interacting beans. One bean can define an event, another bean can fire the event, and yet another bean can handle the event. The beans can be in separate packages and even in separate tiers of the application.

Events may also be fired asynchronously using one of the methods fireAsync(). Event fired with the fireAsync() method is fired asynchronously. All the resolved asynchronous observers are called in one or more different threads. Method fireAsync() returns immediately.

Description of the Example

This example demonstrates the CDI async events APIs. When you click the Start button, an event is fired in the current thread, and the resolved asynchronous observer is called in different a thread.

Use This Example