Durable Event Messaging Example
Durable Event Messaging Example
With durable messaging configured for a client, servers save specified events in queue while the client is disconnected and then play them back when the client reconnects.
You can select which continuous queries or interest registrations are durable, so the server only queues events you really need to retain if your client goes down.
Running the Example
-
In one session, start the server:
$ java -cp "$GEMFIRE/SampleCode/quickstart/classes:$GEMFIRE/lib/server-dependencies.jar" quickstart.DurableServer
-
In another session, start the durable client:
$ java -cp "$GEMFIRE/SampleCode/quickstart/classes:$GEMFIRE/lib/server-dependencies.jar" quickstart.DurableClient
-
After the client starts, press Enter in the server session once or twice to see the events arrive at the client side.
-
Press Enter in the client session to exit the client application.
-
When the client is stopped, in the server session, press Enter twice to create new events.
-
Restart the client application.
You see the events that the server stored for the durable interest played back to the client.
-
Press Enter to exit the client again.
-
Type exit and press Enter to exit the server.
Example Source Files
Program and cache configuration source files for the client and server, including the listener declared in the client and server xml files.
DurableServer.xml | Configures a cache to serve Durable caching clients. The example region also is configured with a loader and listener. |
DurableClient.xml | Configures a region as a client region in a Durable cache. |
DurableServer.java | The server to which the DurableClient connects |
DurableClient.java | The client that connects to the DurableServer.java. |
SimpleCacheListener.java | A CacheListener that reports cache events. |
Related Topics |
---|
How Events Work |
Implementing Durable Client/Server Messaging |
Related Javadocs
- durable-client-id and durable-client-timeout in com.gemstone.gemfire.distributed.DistributedSystem
- readyForEvents and close methods in com.gemstone.gemfire.cache.client.ClientCache
- methods for registering and unregistering interest in com.gemstone.gemfire.cache.Region