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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Available Helper MethodsOnConnect() is available for a <strong>TCP</strong> outbound adapter to call back to its associated business operation. If present inthe business operation, this method is called each time the <strong>TCP</strong> outbound adapter establishes a new connection to orfrom a remote system.If you add an OnConnect() method to your business operation class, it must have the following signature:Method OnConnect(pTimeout As %Numeric) As %StatusImplement an OnConnect() method in your business operation if you need to take some action each time a new connectionis established, for example to send a logon sequence or a handshake token. The timeout argument is automaticallyprovided by the <strong>TCP</strong> outbound adapter. It takes its value from the ConnectTimeout adapter setting. For details, see“Adapter Settings.”Returning an error status from OnConnect() causes the new connection to fail and be disconnected. If an untrappedexception occurs <strong>with</strong>in OnConnect(), the adapter catches it and continues as if OnConnect() were not implemented.5. Compile your new business operation class. Compiling also saves it.6. After creating and compiling the business operation class in Studio, add an instance of the business operation to theproduction and configure it using the Management Portal. See the appendix “Common Tasks in the ManagementPortal.”5.4 Available Helper MethodsWhen your business operation class references the EnsLib.<strong>TCP</strong>.CountedXMLOutboundAdapter, the following adaptermethods become available. You can call these adapter methods from the methods in your business operation class usingthe Adapter property as described in the previous section:Connect()Disconnect()Method Connect(pTimeout As %Numeric) As %StatusConnect() opens a <strong>TCP</strong> socket to a port on the <strong>TCP</strong> listener machine. Connect() has one input argument, a%Numeric value that identifies the number of seconds to wait for the connection attempt to succeed. A typical callto the Connect() method gives this input argument the value of the configurable ConnectTimeout property.If the StayConnected adapter setting is set to –1, the <strong>Ensemble</strong> framework will create the connection automaticallyat startup time, from <strong>with</strong>in the OnInit() method.Method Disconnect()Disconnect() takes down the connection to the <strong>TCP</strong> listener.SendMessageXMLObj()Method SendMessageXMLObj(pRequest As %RegisteredObject,Output pResponse As %RegisteredObject) As %StatusSendMessageXMLObj() sends the request object to the <strong>TCP</strong> listener as a counted XML block. If the GetReplyadapter setting is True, SendMessageXMLObj() also gets a reply from the <strong>TCP</strong> listener as a counted XML block,which it imports as an <strong>Ensemble</strong> object.<strong>Using</strong> <strong>TCP</strong> <strong>Adapters</strong> <strong>with</strong> <strong>Ensemble</strong> 31

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

Saved successfully!

Ooh no, something went wrong!