Book Image

Infinispan data grid platform definitive guide

Book Image

Infinispan data grid platform definitive guide

Overview of this book

Table of Contents (20 chapters)
Infinispan Data Grid Platform Definitive Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Writing event listeners and notifications


It is often useful for the application be aware of some events that occur inside the grid. It provides a better separation of responsibilities and allows developers to implement more generic features and the extension of built-in functionality. Infinispan provides an event notification system for this purpose; this mechanism allows you to register listeners to detect when events take place.

The listener API

Cache-level events such as entries being added, removed, or modified in a specific cache, can trigger a notification that is dispatched to listeners registered to one single cache.

By default, Infinispan will synchronously dispatch the notification to the method object.

Notifications are by default, dispatched synchronously. That is, your callback function will be called in the same thread that is emitting the event. This means that your listener should try to perform quick tasks to avoid blocking the original caller's thread.

If you do need to perform...