JPPF
 Home   About   Download   Documentation   Forums 

Tasks Notifications sample

What does the sample do?

This sample proposes a design to enable JPPF tasks to send real-time notifications, and to allow any client to subscribe to these notifications.

Description of the problem to solve

The goal is to provide an easy to use API that will allow tasks to send simple or complex notifications, so they can report on their progress, or synchronize with external components.

Description of the solution

This feature is implemented via two JPPF extensions for the nodes:
  • A custom node MBean that will send notifications to local or remote listeners using the JMX APIs.
  • A simple facade to the MBean, deployed as a JPPF node startup class, that provides an easy access to the MBean without having to deal with its complexities, initialization, etc.
In addition, we have a JPPF client that will query the server for all attached nodes, connect to each node's JMX server, and subscribe to all notifications from each instance of our custom MBean.

Related source files:

How do I run it?

Before running this sample application, you need to install a JPPF server and at least one node.
For information on how to set up a node and server, please refer to the JPPF documentation.
Once you have installed a server and node, perform the following steps:
  1. open a command prompt in JPPF-x.y.z-samples-pack/TaskNotifications
  2. build the sample: type "ant jar"; this will create a file named TasksNotifications.jar
  3. copy TasksNotifications.jar in the "lib" folder of the JPPF driver installation, to add it to the driver's classpath. This is enough, as the nodes will download the custom MBean and startup class code from the server.
  4. start the server and node
  5. Once you have a server and node, you can either run the "run.bat" script (on Windows), "./run.sh" script (on Linux/Unix) or, from a command prompt, type: "ant run".
  6. you should see the following display:
      [java] received notification: Task '1' : reached stage 1
      [java] received notification: Task '1' : reached stage 2
      [java] ...
      [java] received notification: Task '1' : reached stage 10
      [java] Task 1 successful: the execution was performed successfully

What features of JPPF are demonstrated?

I have additional questions and comments, where can I go?

If you need more insight into the code of this demo, you can consult the Java source files located in the CustomMBeans/src folder.

In addition, There are 2 privileged places you can go to:

Support This Project Copyright © 2005-2011 JPPF.org Powered by Parallel Matters  Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads