Messenger Class

A Messenger class is used to process input data that is submitted to the system in the form of a message. Such messages are submitted through a programmatic API that processes the data through a processing cycle.

Note: Currently, the API supports processing of messages that are in XML format.

The Messenger class contains a built-in cycle for processing input messages. This involves reading and parsing the input message, populating an instance of the Messenger class with the data from the message, and then executing user-defined business rules written as LDL+ logic in built-in methods called Receive() and Respond(). The Messenger class cycle can optionally return a response message.

In addition to the built-in methods you can create user-defined methods. However, there is one important difference with the user-defined methods in a Messenger class compared to all the methods in other types of classes, related to the way in which the return type is defined. In standard methods, throughout the rest of the AB Suite model, the return type of a method is defined by creating a “Return Variable,” which is simply a variable with the same name as the method. Methods within a Messenger class do not have a “Return Variable.” Instead, you define the return type directly through the ReturnType property of the method. This is actually defining a “type” rather than an instance. Therefore, you can return any instance of the specified type from the method logic.

Data Processing in a Messenger Class

Data processing in the Messenger class primarily involves defining the appropriate definitions and logic to receive XML input data and process it – typically to store it in a database or retrieve data from the database, and to respond with output XML data. For example, an input XML document might have customer details,  such as name and address that can be processed through a class named “Customer”. Based on the defined definitions and logic, the customer details can be stored in a database table named CUST. The necessary logic can be defined to assign attributes from the Messenger class instance to an instance of CUST.

At runtime, a client or a protocol adapter calls the Process() method to submit input messages to the system. This method accepts two string arguments: a string containing the XML message and a string with the name of the receiving class; for example “Customer”.

The XML cycle then passes the received message to an instance of the Messenger class; for example, “Customer”. This instance is then populated with the data from the input message. The processing cycle then executes the defined logic to process the input data; for example, to store data or retrieve data from the database.

For a Messenger class to receive an XML input message and process data through an XML cycle, it must be defined with the following:

Stereotype = “Messenger”