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 Methods3. When you want to call one of the methods in EnsLib.<strong>TCP</strong>.TextLineOutboundAdapter, use the Adapter property to identifythe adapter object. In the following example, the Demo.Loan.FindRate<strong>TCP</strong>Operation class calls theEnsLib.<strong>TCP</strong>.TextLineOutboundAdapter method SendMessageString:/// Send an approval to the output <strong>TCP</strong> listenerMethod <strong>TCP</strong>SendReply(pRequest As Demo.Loan.Msg.SendReply,Output pResponse As Ens.Response) As %Status{Set tSC=..Adapter.SendMessageString(pRequest.Text)}Quit tSCYou can use similar syntax to call any of the EnsLib.<strong>TCP</strong>.TextLineOutboundAdapter methods described in “AvailableHelper Methods.”4. Optionally, you may implement the OnConnect() callback method in your business operation class.OnConnect() 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.”7.4 Available Helper MethodsWhen your business operation class references the EnsLib.<strong>TCP</strong>.TextLineOutboundAdapter, the following adapter methodsbecome available. You can call these adapter methods from the methods in your business operation class using the Adapterproperty as described in the previous section:Connect()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.<strong>Using</strong> <strong>TCP</strong> <strong>Adapters</strong> <strong>with</strong> <strong>Ensemble</strong> 47

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

Saved successfully!

Ooh no, something went wrong!