This sample describes the ability of the UltraESB to handle, proxy or mediate a message of almost any format. In this example, we not only proxy a binary Hessian message over HTTP, but if the Hessian classes are available to the runtime, we even show how the UltraESB could read and process the message in transit.
The example also demonstrates the use of an externally defined Java class for mediation, and contains the equivalent in-line code commented 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.
<u:proxy id="hessian-proxy">
<u:transport id="http-8280"/>
<u:target>
<u:inSequence>
<u:class name="org.adroitlogic.ultraesb.core.SampleHessianSequence"/>
<!--<u:java import="java.io.*; com.caucho.hessian.io.*; samples.services.soap.*;"><![CDATA[
InputStream is = msg.getCurrentPayload().getInputStream();
int code = is.read();
int major = is.read();
int minor = is.read();
HessianInput in = new com.caucho.hessian.io.HessianInput(is);
in.skipOptionalCall();
String methodName = in.readMethod();
Object obj = in.readObject(null);
if (obj instanceof GQ) {
GQ gq = (GQ) obj;
System.out.println("Request is for symbol : " + gq.getSymbol());
}
is.close();
]]></u:java>-->
</u:inSequence>
<u:inDestination>
<u:address>http://localhost:9000/hessian/hessian-stockquote</u:address>
</u:inDestination>
<u:outDestination>
<u:address type="response"/>
</u:outDestination>
</u:target>
</u:proxy>
The Proxy service invokes the sequence 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. The commented out fragment shows the equivalent code of the class Sequence when specified in-line.
To try out this sample, start the sample configuration 301 of the UltraESB through the ToolBox, or the command line as follows
asankha@asankha:~/java/ultraesb-1.0-beta-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 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:
Request is for symbol : ADRT
Within the HTTP/S client, you could see the raw Hessian response of content type "application/x-hessian" received as follows

| < Prev | Next > |
|---|


