Symbolic Logic:Programming:Messaging Systems

In communication between computer systems messages need to be exchanged. Often the message will require some transformation to change it from the structure or format produced by the source to the structure or format used by the destination.

Messages need to be routed from the source to the destination. Sometimes the same message may be required at more than one destination (in different formats).

A Messaging System links messages from sources to destination, performing any conversion and routing required.

Often the codes used to identify the same real world objects will be different between the source and the destination. An external reference is the code used to identify an object in another system.

History
Object Oriented programming unified code into one stucture, the class. However a message is data without functionality. It does not fit well into the Object Oriented paradigm.

The OO approach to communicate between systems is to use an interface. Interfaces allow function calls to be made between components, knowing only the interfaces. This may extended to allow communication between separate programs over a network using,


 * DCOM
 * CORBA

However this architecture leads to complex interactions between the systems. Individual calls may be made to set and get attributes. Because each call must wait for confirmation from the other system the approach is too slow.

Another approach would be to clone the object and send it to the other system. However in this approach the functionality must be sent along with the object. This also is not a good solution.

The problem is that function calls are too low level. When we request an action on another system we wish to send all the information in one message. The message contains all the data required to perform the action. Messaging systems implement this approach.

There is an underlying problem with programming languages that is highlighted by this problem. Interactions between components and classes are too complex.

A function call with more than 3 parameters is confusing. In a function call the matching of actual parameter to parameter is by position. For example for a function whose signature is,

a call to make address then looks like,

With so many parameters it is difficult to verify that each actual parameter value matches with the correct formal parameter. This leads us to write code like,

but this distorts the code. The intent was to create an Address in one action at one time. The above code divides that action up into pieces, with a complex interaction over time. Each Set method may have other side effects and set other attributes. It is no longer clear exactly what the above code will do.

Language extensions are needed that allow for the support of messages as an integral part of the language, so that the above call may be written,

Address myAddress = MakeAddress(           UnitNumber(88),            StreetNumber(75),            StreetName("Elm Street"),            StreetType("Street"),            Suburb("Brunswick"),            PostCode(3056),            State("VIC"),            Country("AUSTRALIA")        );

Such code could be written in java / C++, if UnitNumber, StreetNumber, ... were classes with appropriate constructors. But that is not the intent here. The intent here is to pass the data to MakeAddress as a single structured message, so that an Address may be constructed from the data.

Defining a Message
In constructing a message we would like compile time checking that the message is correct. In addition we would like to construct a message within the language for use in calling functions internally. The same problem exists when communicating with a system as with communicating to an external system. We would like to send all the data in one function call.

The Role of XML
The syntax of XML does not fit in with a language liken Java or C++. XML also has some nasty features.
 * The DTD is overly complicated.
 * There is too many ways of doing the same thing.
 * Attribute or data.
 * It is not easy to define an unordered collection of elements (where there is one of each element).
 * Because each element has its own tag, in many situations it is unnecessary and a nuisance to define an order for the elements.

Language Features for Constructing Messages
Need to be able to define a message as part of the language. Something like,

x = Person (         Name ( GivenName ("Joe"), MiddleName ("John"), Surname ("Blogs") ),         Address ( Unit (95), StreetNumber (43) StreetName ("River"), StreetType ("Road"), Suburb ("GEORGETOWN"), PostCode (4005), State ("Tasmania"), Country ("AUSTRALIA") )     );

This type of structure is similar to an Algebraic Data Type.

This needs to be an integrated part of the language, but not to be a constructor. This is just structured data from which an object may be constructed later.

Data Type Definition
We need to be able to define a data type,

datatype PersonMessage = Person (          Name ( GivenName ( String ) & MiddleName ( String ) & Surname ( String ) ),          Address ( Unit ( long ) & StreetNumber ( long ) & StreetName ( String ) & StreetType ( String ) & Suburb ( String ) & PostCode ( long ) & State ( String ) & Country ( String ) )      );

The & symbol means that each element only occurs once. The elements may be in any order.

Accessing the structure
Need to be able to access parts of the structure. E.g.

streetName = x.Person.Address.StreetName;

This is like an xml query path.

Conversion to XML and other Formats
We need to be able to convert a data type to XML or any other format. This means that we need to be able to traverse the message and access,
 * Values
 * Tag names

???? How to allow this in the language ????

Message Formatting
There are many formats used for the transfer of messages. Many are propriety, or legacy. In modern times XML is the message format of preference.

Whatever the message format is, middle-ware messaging systems can convert it to another format. The source system produces the message in the format it wants and the destination system receives the message in the format that it can read.

Message Routing
The messaging system may be configured to send data to one or more destinations. A Routing Script may be used to choose where individual messages are sent.

Message Mapping
A message mapping script uses information from an input message to construct an output message. The format of the message is not changed.

Message header
A message header records information about the message. It is used in routing the message to the correct destination and in the interpretation of the message.

Links

 * Symbolic Logic:Programming:Framework
 * Symbolic Logic:Programming
 * Intelligence and Reasoning