PEX Business Operations
Business operations connect with external systems and send messages to them via an outbound adapter.
For general information related to all production components written in a PEX-supported language, see About Business Hosts and Adapters.
Developing a Business Operation
To write a business operation in an external language, extend one of the following classes:
Language | Class |
---|---|
Java | com.intersystems.enslib.pex.BusinessOperation |
.NET | InterSystems.EnsLib.PEX.BusinessOperation |
Python | iris.pex.BusinessOperation |
Implementing Abstract Methods
At runtime, the OnMessage() method is called when the business operation receives a message from another business host. From within this method, the business operation can call any of the methods defined in the outbound adapter associated with the business operation. Parameters for calls from a business operation to an outbound adapter do not need to be persistent.
For details on other abstract methods that need to be implemented, see PEX API Reference.
Using an Outbound Adapter
Within a production, a business operation uses an outbound adapter to communicate with systems outside the production. When developing a PEX business operation, you can include a special method in the remote class to define which outbound adapter the business operation uses. This outbound adapter can be a PEX adapter or a native ObjectScript adapter.
The method used to specify the outbound adapter for the PEX business operation is getAdapterType(). For example, if the PEX business operation uses a custom PEX outbound adapter, your remote class might include:
public String getAdapterType() {
return "com.demo.pex.MyOutboundAdapter";
}
public override string getAdapterType() {
return "Demo.PEX.MyOutboundAdapter";
}
def getAdapterType():
return "demo.PEX.MyOutboundAdapter"
When using a PEX adapter, the getAdapterType method should return the name of the ObjectScript proxy class that was specified when the adapter was registered. By default, this proxy name is the same as the remote class, but a custom name might have been defined.
Invoking Adapter Methods
A business operation uses its outbound adapter by invoking methods defined in the adapter’s code. The syntax for invoking these methods varies depending on whether the business operation is a PEX component or a native ObjectScript class. For details on invoking the PEX adapter methods from a native business operation, see Accessing Properties and Methods from a Business Host.
If your business operation is a PEX component, use Adapter.invoke() to call the adapter’s method. Its signature is:
Adapter.invoke("methodName", arguments)
Where:
-
methodName specifies the name of the method in the outbound adapter to be executed.
-
arguments contains the arguments of the specified method.
For example, to invoke the adapter’s printString method, add the following code to your business operation:
public Object OnMessage(Object request) throws Exception {
MyRequest myReq = (MyRequest)request;
Adapter.invoke("printString", myReq.requestString);
}
public override object OnMessage(object request)
{
MyRequest myReq = (MyRequest)request;
Adapter.invoke("printString", myReq.RequestString);
}
def OnMessage(self, messageInput):
self.Adapter.invoke("printString", messageInput.requestString)
return
When the business operation passes a primitive to the adapter, the same primitive is received by the adapter. However, by default, when the business operation passes an object to the adapter, the object is serialized into JSON and received by the adapter as an IRISObject type. If you want to change this behavior so the adapter receives and returns the same object type, see Sharing a Connection.
Using the Business Operation
Once you have finished developing the remote class of the PEX business operation, you can complete the following steps to integrate the business operation into an interoperability production:
-
Register the PEX business operation by navigating to Interoperability > Configure > Production EXtensions Components. For details, see Registering a PEX Component.
-
Open the production and use the standard wizard to add a business operation. In the Operation Class field, select the ObjectScript proxy class of the PEX component. By default, the name of this proxy class matches the remote class, but a custom name might have been defined when the component was registered.