Sequences and Mediation

A Sequence defines the mediation actions to be performed on a message. A Sequence may be defined in-line and locally to a proxy service (see image below - 3), or defined as a re-usable sequence with an ID and referenced as many times as needed (see image below - 1 & 2 - an error handling sequence is reused at service level as well as sequence level).

sequence definition

The current message is exposed by a special variable "msg", while the Mediation instance by the variable"mediation" and a Log4j logger instance by the variable "logger". The interfaces Message and Mediation in the UltraESB API package allows one to perform almost anything within a sequence. The end user is also free to invoke any third party classes, Spring beans, or class libraries as appropriate for his/her mediation requirements. However, one should be careful about spawning new threads etc from within a sequence, as the UltraESB manages the execution threads which invokes sequences.

A sequence can specify another sequence as its error handler. In the above example, the "inSequence" of the proxy service specifies the sequence with the ID "sequenceErrorHandler" as its error handler, and hence on an un-handled exception, the error handler sequence would be invoked. If no sequence error handler exists, or if a sequence error handler throws an exception, the service level error handler (#1 above) would be invoked. A sequence can make use of the Java exception handling support such as try-catch-finally, custom exceptions etc.

A sequence maybe specified as a Java or JSR 223 script fragment, class or Spring bean, or a source file. Irrespective of the style of definition, each sequence executes as native byte-code on the JVM where the scripting language supports compilation. The special variables and the public API visible for Java and JSR 233 scripting languages are identical. However, JSR 223 languages may have some special abilities native to them which maybe useful during mediation.

reusable sequence groovy

The UltraESB supports Sequences defined as follows, see the Sequence and Mediation Development for more details.

  • Java code fragment / snippet

  • JSR 223 scripting language fragment / snippet

  • Java source file

  • Script source file

  • Class file / byte code

  • Spring bean

While the API documentation provides the complete reference of the operations available to use in mediation, the Mediation Reference describes those operations from the usage perspective, where it will be easy to map your requirement usage into the required API call and how to effectively call it.

In this topic
In this topic
Contact Us