Skip to main content

PEX 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

Implementing Abstract Methods

Typically, the inbound adapter’s OnTask() method performs the main function of the adapter. At runtime, the OnTask() method is called at the interval specified in the settings for the business host 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);
  return;
}

public override void OnTask()
{
  SimpleObject request = new SimpleObject("message #" + (++runningCount));
  // send object to business service's ProcessInput() method
  string response = (string)BusinessHost.ProcessInput(request);
  return;
}
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)
  return

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.

By default, the object sent from the adapter to the business service is serialized into JSON and received by the service as an IRISObject type. However, if the adapter and business service share a connection, the business service can receive and return the same object type, which has advantages. For details, see Sharing a Connection.

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.

Registering the Adapter

Once you are done writing the code for the PEX adapter, you are ready to register it. Registering the adapter generates an ObjectScript proxy class that a business service can use to identify the adapter and defines the external language server that the production uses to connect to the adapter. For details on registering the adapter, see Registering a PEX Component.

Adding the Adapter to a Business Service

A PEX adapter can be used by a PEX business service or by a native ObjectScript business service. The process of configuring a business service so it uses the PEX adapter varies depending on the type of business service. Both scenarios require the adapter to be registered as a PEX component.

When a PEX business service is using the PEX adapter, the remote class of the business service uses a method to identify the adapter. For details, see Using an Inbound Adapter.

Like all native ObjectScript business services, a native business service using a PEX adapter identifies the adapter using an ADAPTER parameter. In this case, the ADAPTER parameter is set to the name of the PEX adapter’s ObjectScript proxy class. By default, this proxy class shares the name of the adapter’s remote class, but a custom proxy name might have been defined when the adapter was registered.

FeedbackOpens in a new tab