Java user-defined message processing nodes life cycle

During the lifecycle of the user-defined nodes that you create in Java™, objects are created and destroyed, and different methods and classes called.

Every node goes through the following stages:

  • Registration
  • Instantiation
  • Processing
  • Destruction

The information here applies to both output nodes and message processing nodes. Both of these node types can be considered together, because although a message processing node is typically used to process a message, and an output node is used to provide an output, in the form of a bit stream, from a message, you can use both types of node to perform either of these functions.

Registration

The registration phase occurs when a user-defined message processing node that is written in Java contacts the integration node, or registers with the integration node.

Whenever an integration node starts, it loads all relevant LIL files and Java classes. To ensure that a message processing node is registered with the integration node, you must provide the integration node with a class that implements the MbNodeInterface interface and is contained in the classpath used by the integration node.

Instantiation

A Java user-defined message processing node is instantiated when an integration node deploys a message flow that contains the user-defined message processing node. When the node is instantiated, the constructor of the message processing node class is called.

When a node is instantiated, all terminals that you have specified are created. A message processing node can have an unlimited number of input and output terminals associated with it. You must include the createInputTerminal and createOutputTerminal methods in your node constructor to declare these terminals.

Output terminals include out, failure, and catch terminals. Use the createOutputTerminal class within the node class constructor in order to create as many output terminals as you require.

As a minimum, you must create only these output terminals by using your constructor class. However, if you need to initialize attribute values, you must also include that code at this point in your message processing node.

If you want to handle exceptions that are passed back to your message processing node, it is good practice to do this by creating a failure terminal for your user-defined message processing node, by using the createOutputTerminal method. It is sensible to use the failure terminal for this process because that is the terminal to which errors are propagated.

Make sure that all exceptions that are caught by the message processing node are dealt with properly. If you do not include a failure terminal, the message processing node does not attempt to handle the exception. If your message flow does not contain a method of exception handling, all exceptions thrown are passed back to the input node, where the input node deals with the exceptions.

If you do catch exceptions, make sure that you rethrow all exceptions that the message processing node cannot deal with. This action causes the exception to be passed back to the input node for handling; for example, when you want to rollback a transaction.

Processing

During the processing phase of the life cycle of a user-defined message processing node, the message processing node takes the logical hierarchy of the message and processes it in some way.

Destruction

A Java user-defined message processing node is destroyed when the node is deleted, or the integration node is shut down. You do not have to include anything in your code to specify that the node is physically deleted, because this process can be handled by the garbage collector.

However, if you want notification that a node is about to be deleted, you can use the onDelete method. You might want to receive notification if the node has resources that you want to delete, other than those that will be garbage collected. For example, if you have opened a socket, it is not properly closed when the node is automatically deleted. You can include this instruction in your onDelete method to ensure that the socket is closed properly.