Persisting an Event Queue

You can configure a gateway sender queue or an asynchronous event queue to persist data to disk similar to the way in which replicated regions are persisted.

Persisting a queue provides high availability for the event messaging that the sender performs. For example, if a persistent gateway sender queue exits for any reason, when the member that hosts the sender restarts it automatically reloads the queue and resumes sending messages. If an asynchronous event queue exits for any reason, write-back caching can resume where it left off when the queue is brought back online.

GemFire persists an event queue if you set the enable-persistence attribute to true. The queue is persisted to the disk store specified in the queue's disk-store-name attribute, or to the default disk store if you do not specify a store name.

When you enable persistence for a queue, the maximum-queue-memory attribute determines how much memory the queue can consume before it overflows to disk. By default, this value is set to 100MB.

Note: If you configure a parallel queue and/or you configure multiple dispatcher threads for a serial queue, the values that are defined in the maximum-queue-memory and disk-store-name attributes apply to each instance of the queue.
In the example below each gateway sender queue uses "diskStoreA" for persistence and overflow, and the queue has a maximum queue memory of 100MB:
  • XML example:
      <gateway-sender id="persistedsender1" parallel="false" 
  • API example:
    Cache cache = new CacheFactory().create();
    GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
    GatewaySender sender = gateway.create("persistedsender1", "1");

If you were to configure 10 dispatcher threads for the above gateway sender, then the total maximum memory for the gateway sender queue would be 1000MB on each GemFire member that hosted the sender.

The following example shows a similar configuration for an asynchronous event queue:
  • XML example:
       <async-event-queue id="persistentAsyncQueue" persistent="true"
        disk-store-name="diskStoreA" parallel="true">
             <parameter name="url"> 
             <parameter name="username"> 
             <parameter name="password"> 
  • API example:
    Cache cache = new CacheFactory().create();
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    AsyncEventListener listener = new MyAsyncEventListener();
    AsyncEventQueue persistentAsyncQueue = factory.create("customerWB", listener);