Skip to main content

Inbound Adapters

Business services use inbound adapters to receive specific types of input data. You can write a custom inbound adapter that is used by an ObjectScript business service, or it can be used by a business service that is also written in a PEX-supported language. For general information related to all production components written in an external language, see About Business Hosts and Adapters.

Developing a Custom Adapter

To begin the process of writing a custom inbound adapter in an external language, extend one of the following classes:

Language Class
Java com.intersystems.enslib.pex.InboundAdapter
.NET InterSystems.EnsLib.PEX.InboundAdapter
Python iris.pex.InboundAdapter

Typically, the inbound adapter’s OnTask() method performs the main function of the adapter. At runtime, the OnTask() method is called at the interval defined in the business service that is using the adapter. From within OnTask(), call BusinessHost.ProcessInput() to dispatch an object to the associated business service’s ProcessInput method. For example, a simple adapter might include:

public void OnTask() throws Exception {
  SimpleObject request = new SimpleObject("message #"+(++runningCount));
  // send object to business service's ProcessInput() method
  String response = (String) BusinessHost.ProcessInput(request);
public override void OnTask()
  SimpleObject request = new SimpleObject("message #" + (++runningCount));
  // send object to business service's ProcessInput() method
  string response = (string)BusinessHost.ProcessInput(request);
def OnTask(self):
  msg = "this is message # %d" %self.runningCount
  request = demo.SimpleObject(msg)
  # send object to business service's ProcessInput() method
  response = self.BusinessHost.ProcessInput(request)

The object sent from the adapter’s BusinessHost.ProcessInput call to the business service’s ProcessInput method is arbitrary and does not need to be persistent within InterSystems IRIS. The same is true for the object returned by the business service’s ProcessInput method to the adapter.

At a minimum, your adapter must implement the superclass’ OnInit, OnTearDown, and OnTask methods. For details on these and other methods of an inbound adapter, see the PEX API Reference.

Adding Your Adapter to a Business Service

Once you have written your custom inbound adapter in an external language, you are ready to define a business service to use the adapter. The ObjectScript class for your business service must include:

Parameter ADAPTER = "EnsLib.PEX.InboundAdapter"

If your production is using a custom PEX business service, subclass EnsLib.PEX.BusinessService and define the ADAPTER parameter. If you are using a native ObjectScript business service, subclass Ens.BusinessService and add the parameter.

Once you have your business service subclass, add it to your production using the Management Portal. The Remote InboundAdapter settings of this business service, which are available in the Management Portal, define the details of the adapter.

Remote InboundAdapter Setting Description
Remote Classname Specifies the name of the inbound adapter class that you wrote in the external language.
Remote Settings Allows you to specify values of runtime variables. For more details, see Setting Runtime Variables.
External Server Name Specifies the name of the external server for your language. For more details, see Running the External Server. If you use this setting, you do not need to define the Gateway Host and Gateway Port settings.
Gateway Extra Classpath Specifies paths to packages, files, libraries or binaries, files, and directories needed by your application. If you already defined these paths when setting up a custom external server for your language, you do not need to repeat them here. Using the pipe character (|) to separate paths is accepted on all operating systems.