Hessian Binary Message Proxying

Sample Number





This sample demonstrates the usage of UltraESB to mediate Hessian messages

Use Case

I want to proxy a binary Hessian message over HTTP with the ESB. At the same time, if the Hessian classes are available to the runtime, I want to read and process (mediate) the message in transit with a pre compiled Java class.

hessian proxy

As shown in the above diagram, instead of directly talking to the Hessian service, UltraESB acts as the proxy for all the requests going to the back-end server. Within the UltraESB we process the message to print some information extracted from the message.

Sample Configuration

The configuration for this use case consists of a proxy service identified as "hessian-proxy", exposed on the HTTP transport and forwards the incoming message into the target back-end service configured using the in destination of the proxy service. An in sequence as a Java class file, defined in the SampleHessianSequence class, which performs a bit of standard Hessian processing to determine the version and method call for the request passing through, is configured to process the message before forwarding the accepted messages to the in destination.

Hessian binary proxy configuration with mediation

 1<u:proxy id="hessian-proxy">
 2  <u:transport id="http-8280"/>
 3    <u:target>
 4      <u:inSequence>
 5        <u:class name="org.adroitlogic.ultraesb.core.SampleHessianSequence"/>
 6        <!--<u:java import="java.io.*; com.caucho.hessian.io.*; samples.services.soap.*;"><![CDATA[
 7          InputStream is = msg.getCurrentPayload().getInputStream();
 8          int code = is.read();
 9          int major = is.read();
10          int minor = is.read();
11          HessianInput in = new com.caucho.hessian.io.HessianInput(is);
12          in.skipOptionalCall();
13          String methodName = in.readMethod();
14          Object obj = in.readObject(null);
15          if (obj instanceof GQ) {
16            GQ gq = (GQ) obj;
17            System.out.println("Request is for symbol : " + gq.getSymbol());
18          }
19          is.close();
20        ]]></u:java>-->
21      </u:inSequence>
22    <u:inDestination>
23      <u:address>http://localhost:9000/hessian/hessian-stockquote</u:address>
24    </u:inDestination>
25    <u:outDestination>
26      <u:address type="response"/>
27    </u:outDestination>
28  </u:target>

The above configuration also presents a commented out equivalent in-line code to the Java class for user to easily experiment. If required and if the actual class file/s are available, it is possible to read and even modify a Hessian binary message in-flight through the UltraESB.

The compiled class sequence demonstrates the capability to use a pre-compiled sequence for mediation of messages, so that organizations could develop, test, verify and deploy validated code on the UltraESB and ensure that configuration mistakes will not have an impact.

In Action

To run the example, start the UltraESB sample configuration 301 via the ToolBox or on the command line as follows.

Running the sample from startup script

$ cd /opt/ultraesb-2.6.1/bin
$ ./ultraesb.sh -sample 301 

To issue a Hessian request, you may refer the unit test HessianTest.java or use the advanced capabilities of the SOA Toolbox - which allows one to even capture a Hessian payload to a binary file, and then re-issue it again through the HTTP/S client. For simplicity we have already captured such a request through the ToolBox and shipped it as a binary file.

Start the sample Jetty server, and the HTTP/S client of the ToolBox and select the samples/resources/hessian-request.bytes from the file system, and issue it against the proxy URL http://localhost:8280/service/hessian-proxy. On the UltraESB console, you could now see that the message Hessian payload has indeed been read from the message;

UltraESB console output for the message invocation

Request is for symbol : ADRT

Within the HTTP/S client, you could see the raw Hessian response received as follows;

hessian proxy client
In this topic
In this topic
Contact Us