Methods for a .NETInput node

The methods that you can implement in a .NETInput node depends on if you are using polling or event style message flows.

The API for the .NETInput node is called the Connector API. This API is in the IBM.Broker.Plugin.Connector namespace.

Initialize
The Initialize method is called when a message flow that contains the .NETInput node is deployed to an integration server. If an exception is thrown from Initialize, it rolls back the deployment of the flow.
Start
Use the Start method to create any required connections to the end system from which the .NETInput node retrieves data. This method is called after the Initialize method, when a message flow that contains the .NETInput node is successfully deployed.

If the Start method throws an exception, then it does not influence the result of the deployment of the message flow. Such an exception reports an error to the system log, and the Start method is called again after a short wait.

Event Connectors

Diagram of an MSMQ application input into a .NETInput node.

If you are using the event-driven style of .NETInput node, then you must register a user-defined delegate with the application that is the source of the events, which drive the .NETInput node. If you use the event-driven style and do not register a delegate in the Start method, then there is no way for the .NETInput node to propagate data to the message flow threads. The User Delegate method is responsible for creating NBEvent objects and passing them to the DeliverEvent method provided on the NBEventConnector class. The DeliverEvent method puts data on an in-memory queue, which the message flow threads access to pass the data in the NBEvent object.

ReadData

Polling-driven Connectors

Diagram of the .NETInput node in an example MSMQ configuration, sending ReadData() back to the MSMQ queue.
If you are using the polling style of .NETInput node, you must implement the ReadData method from the NBPollingConnector base class. Your ReadData method is called by the internal code of the integration node, so a .NETInput node developer implements the method only, and is not responsible for providing code that actually calls the method. Therefore, the .NETInput is not responsible for implementing any recursive polling logic, and so it is not necessary or suitable to code a loop or use a Sleep method as part of ReadData.

The integration node runs the ReadData method automatically after the message flow finishes deploying, when the Start method returns without an exception.

The ReadData method is responsible for taking data from the data source, if available, and returns an instance of the NBPollingResult object. If data is available, the returned NBPollingResult object is either a built-in NBByteArrayPollingResult, which creates the output message directly from the byte array, or a user-defined subclass, from which you can create the message tree manually.

See the following diagram for an example of using polling with the ReadData method.

Diagram of a flow thread for a polling style .NETInput node, with wait intervals.

If no data is available, the node developer returns an NBTimeoutPollingResult. When the ReadData method has finished waiting for the passed in timeout duration (T1), use the single-argument constructor for NBTimeoutPollingResult. If the data source does not allow a timed wait, use the two-argument constructor to return a timeout value back to the integration node. In this case, the integration node waits for this timeout interval (T2) before it calls ReadData again. This use of the method allows a developer for the .NETInput node to control the duration of the interval between polls (T2).

For example, you can implement a batch style of operation, requesting that the ReadData method is only called once per hour, or once per day.

Finish
The Finish method is called when the .NETInput node that is using the connector must stop receiving data. When you remove a message flow that contains a .NETInput node that is deployed to an integration server, the Finish method is called before the Terminate method. If the Finish method throws an exception, then the error is reported to the system log, and the connector is placed into stopped state. This method is a good place to close connections or handles, or similar.
Terminate
The Terminate method is called when a message flow containing the .NETInput node is removed from an integration server. This method always provides a way for your code to end cleanly if you want to do anything before you remove a deployed message flow that contains a .NETInput node.