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 fromInitialize
, 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 theInitialize
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 theStart
method is called again after a short wait.Event Connectors
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. TheUser Delegate
method is responsible for creatingNBEvent
objects and passing them to theDeliverEvent
method provided on theNBEventConnector
class. TheDeliverEvent
method puts data on an in-memory queue, which the message flow threads access to pass the data in theNBEvent
object. ReadData
Polling-driven Connectors
If you are using the polling style of .NETInput node, you must implement theReadData
method from theNBPollingConnector
base class. YourReadData
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 ofReadData
.The integration node runs the
ReadData
method automatically after the message flow finishes deploying, when theStart
method returns without an exception.The
ReadData
method is responsible for taking data from the data source, if available, and returns an instance of theNBPollingResult
object. If data is available, the returnedNBPollingResult
object is either a built-inNBByteArrayPollingResult
, 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.If no data is available, the node developer returns an
NBTimeoutPollingResult
. When theReadData
method has finished waiting for the passed in timeout duration (T1), use the single-argument constructor forNBTimeoutPollingResult
. 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 callsReadData
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, theFinish
method is called before theTerminate
method. If theFinish
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.