10.07.2015 Views

Using TCP Adapters with Ensemble - InterSystems Documentation

Using TCP Adapters with Ensemble - InterSystems Documentation

Using TCP Adapters with Ensemble - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Customizing Callbacks of Inbound <strong>TCP</strong> <strong>Adapters</strong>8.3 Customizing Callbacks of Inbound <strong>TCP</strong> <strong>Adapters</strong>If you subclass or copy an inbound <strong>TCP</strong> adapter, you can override these methods <strong>with</strong> unique behaviors:OnConnected()OnInit()Method OnConnected() As %StatusWhenever a connection exists to the configured <strong>TCP</strong> client, the adapter calls OnConnected() to read a streamfrom the <strong>TCP</strong> data source. This read operation is controlled by adapter settings.OnConnected() uses helper methods to parse the data.Upon successfully reading data, OnConnected() calls the <strong>Ensemble</strong> framework’s ProcessInput() method to passthe received data stream to the associated business service. If this call returns an outbound stream, OnConnected()writes that data as a reply to the <strong>TCP</strong> client.If no data is available to read from the <strong>TCP</strong> connection during the CallInterval time, OnConnected() returns<strong>with</strong>out doing anything.Also see the OnTask() method.Method OnInit() As %StatusThe <strong>Ensemble</strong> framework calls OnInit() after creating the inbound adapter instance and setting its configurableproperty values. The OnInit() method provides a way for the inbound adapter to perform any special setup actions.Depending on the values of the relevant adapter settings, one of these actions might be to initiate a connectionbetween the adapter and the <strong>TCP</strong> client it will listen to, or to construct any object properties that the adapter willuse.OnTearDown()OnTask()Method OnTearDown() As %StatusThe <strong>Ensemble</strong> framework calls OnTearDown() during shutdown, before destroying the inbound adapter object.The OnTearDown() method provides a way for an inbound adapter to perform any special cleanup actions suchas disconnecting from the <strong>TCP</strong> client.Method OnTask() As %StatusAll inbound adapters have an OnTask() method, where the bulk of the adapter work is done. Once a productionstarts, each business service calls the OnTask() method of its associated inbound adapter class, at the time intervaldetermined by the adapter’s CallInterval setting. For details, see “Business Service Life Cycle” in the “BusinessServices” in Developing <strong>Ensemble</strong> Productions.For more detailed information about adapter class internals, open the class in Studio or use the <strong>InterSystems</strong> Class Reference.8.4 Customizing Callbacks of Outbound <strong>TCP</strong> <strong>Adapters</strong>If you subclass or copy an outbound <strong>TCP</strong> adapter, you can override these methods <strong>with</strong> unique behaviors:<strong>Using</strong> <strong>TCP</strong> <strong>Adapters</strong> <strong>with</strong> <strong>Ensemble</strong> 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!