Go to main content

Developing Data Services

Exit Print View

Updated: August 2018

Example of Creating a Java Application That Uses the CRNP

The following example illustrates how to develop a simple Java application named CrnpClient that uses the CRNP. The application registers for event callbacks with the CRNP server in the cluster, listens for the event callbacks, and processes the events by printing their contents. Before terminating, the application unregisters its request for event callbacks.

    Note the following points when reviewing this example:

  • The sample application generates and parses XML with the JAXP (Java API for XML Processing). This example does not show you how to use the JAXP. The JAXP is described in more detail at https://docs.oracle.com/javase/9/.

  • This example presents pieces of an application, which can be found in its entirety in CrnpClient.java Application. To illustrate particular concepts more effectively, the example in this chapter differs slightly from the complete application that is presented in CrnpClient.java Application.

  • For brevity, comments are excluded from the sample code in this chapter. The complete application in CrnpClient.java Application includes comments.

  • The application that is shown in this example handles most error conditions by simply exiting the application. Your actual application needs to handle errors more robustly.