Distributed Messaging for Runtime Data Sharing

The need to share data at runtime is increasing in modern applications. Since, relational databases have an inefficient event notification mechanism, this raises a major question mark on their performance and scalability.

Although, message queues do provide sequenced messages and guarantees of message delivery they also have scalability and performance issues.

The best way then is to use a distributed messaging platform with a message bus style, which is not only fast and scalable but also provides data sharing coordination in a producer/consumer style. A strong event notifications feature for an In-Memory Data Grid is an ideal way to achieve this goal. TayzGrid is an elastic In-Memory Data Grid which provides a simple yet powerful message bus style distributed messaging capability.

Distributed Messaging Events

With TayzGrid distributed messaging, you can do the following:

  1. Data grid level events: if the client has registered for receiving event notifications for changes to items in the data grid, then TayzGrid notifies clients on add, insert, and remove of any item in the data grid.
  2. Continuous Query events: a dataset in the data grid can also be monitored by TayzGrid based on SQL-like criteria and then it notifies clients for add, update, and remove of items from this data set to clients who have registered for these notifications.
  3. Application initiated (topic based) events: Applications can also fire topics based custom events into TayzGrid message bus so that other interested applications can be notified.

Distributed Messaging for Runtime Data Sharing

All the Java or .NET applications connected to TayzGrid can use it as a distributed messaging platform. They can also propagate events to other applications and ask to notify for changes in the data grid.

Data Grid Level Events

When anything is added, updated, or removed from the data grid or if the data grid is cleared, data grid level events are fired. These events are turned off by default because of their chatty nature. However, you can enable some or all of them in the data grid configurations and then have your application supply callback functions to TayzGrid so it calls these callbacks when these events occur.

MutableCacheEntryListenerConfiguration _listenerConfig = null;

_listenerConfig = new MutableCacheEntryListenerConfiguration(
		[isOldValueRequired], [isSynchronous]


Continuous Query

Continuous Query is a powerful feature which allows you to register an SQL-like query with the data grid and also specify events for which you would like to have callbacks to be called by TayzGrid.

It creates a Continuous Query in the in-memory data grid. It monitors all add, update, and remove operations to the data grid to see if these operations modify stored items in the data grid matching the criteria set by Continuous Query. If so, then it notifies your client application about it.

Below are the events you can register:

ContinuousQuery continuousQuery = new ContinuousQuery(query, values);
  //Item added notification
  continuousQuery.RegisterAddNotification(new ContinuousQueryItemAddedCallback() {
    public void continuousQueryItemAdded(String string) {

  //Item update notification
  continuousQuery.RegisterUpdateNotification(new ContinuousQueryItemUpdatedCallback() {
    public void continuousQueryItemUpdated(String string) {

  //Item delete notification
  continuousQuery.RegisterRemoveNotification(new ContinuousQueryItemRemovedCallback() {
  public void continuousQueryItemRemoved(String string) {

Application Initiated Custom Events

TayzGrid also allows your applications to coordinate with each other in a producer/consumer or publisher/subscriber model. One application produces data and then fires a custom event into the distributed messaging bus. Other applications are waiting to receive this event. Here is an example how your application can register to receive these custom events.

Implement CustomListener interface as follows:

import com.alachisoft.tayzgrid.event.*; 

public class CacheEventListner implements CustomListener
  public void customEventOccured(CustomEvent event)
      System.out.println("Custom EVENT :- Custom 
      event is raised for Key[ " + event.getKey() + " ] 
      with value: " + event.getSource().toString());

What to Do Next?