Client Status Monitor Sample


This sample demonstrates how to monitor the status of StreamBase clients using the Java Client API. The sample provides a Java StreamBase client application that connects to a simple EventFlow application running in StreamBase Server, and tracks the status of its own connection to the server in four ways:

  1. It registers a callback to be notified of status changes.

  2. It uses a timer to periodically check the status.

  3. It uses a dequeue result to periodically check the status.

  4. It sets the system property streambase.client.log-connection-status to true, which causes the StreamBase client to log the results at elevated log levels. This property is set as part of the run configuration saved as ClientStatusMonitor.launch. See StreamBase Java Properties for more on this system property.

For detailed information about the API methods used in this sample, refer to the Java Client API Javadoc.


The Java code in this sample is delivered only in source code form. To build the code, you must load the sample into StreamBase Studio, which automatically builds the Java code.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter client status to narrow the list of options.

  • Select Illustrates mechanisms for tracking client connection status from the Client Libraries category.

  • Click Import Now.

StreamBase Studio creates a single project containing the sample files.

Running This Sample in Studio

  1. Open the src/main/eventflow/packageName folder.

  2. Double-click to open DoNothing.sbapp. Make sure the application is the currently active tab in the EventFlow Editor.

  3. Click the Run button. This opens the SB Test/Debug perspective and starts the module.

  4. Return to the SB Authoring perspective.

  5. Run the ClientStatusMonitor Java application by right-clicking the ClientStatusMonitor.launch file in the Project Explorer view and selecting Run As>ClientStatusMonitor.


    Do not select the Java file itself and use Run As>Java Application. This does run the client program, but unlike using the .launch file, this method does not set the required URI argument or the required Java system property. Thus, running the Java client application this way is guaranteed to fail.

  6. Scroll to the right In the Console view, and observe the various connection status reports:

    INFO  c.s.s.c.status.ClientStatusMonitor - Callback Status ->
    INFO  c.s.s.c.status.ClientStatusMonitor - Periodic Check ->
    INFO  c.s.s.c.status.ClientStatusMonitor - Dequeue -> 
  7. Return to the SB Test/Debug perspective. In the Manual Input tab, enqueue tuples on the input stream, and scroll right in the Console view to observe Status=GOOD events in the output:

    Dequeue (Status=GOOD, ClientID=C3C33649299F0733053DBD822BC8B7D4, 
       1 tuples dequeued)
    Dequeue (Status=GOOD, ClientID=C3C33649299F0733053DBD822BC8B7D4, 
       2 tuples dequeued)
  8. To stop running this sample requires two steps, in the following order:

    1. Stop the client application by clicking the red Terminate button in the toolbar of the Console view.

    2. Stop the EventFlow application by pressing F9 or clicking the Terminate EventFlow Fragment button.

This Sample's Files

The ClientStatusMonitor sample includes the following files:

Java client application that monitors its own connection status as described above.


Launch configuration file that (1) sets the system property described above, then (2) runs the Java client application with a default URI argument of sb://localhost:1000.

You can modify these settings by invoking Run>Run Configurations and selecting the configuration for ClientStatusMonitor in the Java Application tree. (This launch configuration might not appear in the dialog until you have successfully run it at least once.)


Sample EventFlow application with a pass-through Map operator. The only purpose of this module is to present a running application to which the Java client program can connect.

Sample Location

When you load the sample into StreamBase® Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.


Load this sample in StreamBase® Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:


See Default Installation Directories for the default location of studio-workspace on your system.