users@grizzly.java.net

Re: Asynchronous Request Processing with TCPIP

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 02 Jul 2008 10:53:23 -0400

Salut,

[removing the dev alias]

Vishnuvardhan wrote:
> Hi
>
> I am working on Open ESB HL7 binding component. We are in the processing
> of migrating the component from Apache Mina framework to Grizzly. I
> would like to know if I can do Asynchronous Request Processing with TCP
> using Grizzly.
>
> This is what I want to do.
> 1. Listen on a particular port.
> 2. Read the incoming message.
> 3. Parse the incoming message.
> 4. Submit the parsed message to the business processing layer.
> 5. Once a response is available, send back the response message to the
> same socket.

Yes, you can. Take a look at the SuspendableFilter:

https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/suspendable/SuspendableFilter.html


>
> This is what I have done.
> 1. Created a Controller.
> 2. Added a protocol chain with ReadFilter and a parser filter.
> 3. Once the message is available, submitting the message to the business
> processing layer.
> The thread execution ends here.
>
> The response will be available from another thread. Now, I want to write
> the response message back to the same socket. I tried to cache the
> context from 1st thread and tried to use the same context for writing.
> But when I say ctx.getSelectionKey().channel(), the program hangs there.
>
> I went through the blog on Asynchronous Request Processing by
> Jean-Francois Arcand's Blog <http://weblogs.java.net/blog/jfarcand/>.
> The framework seems to be supporting only HTTP protocol.
>
> Can somebody guide me how to achieve this in TCP IP.

Take a look at the SuspendableFilter as I think this is really what you
need. You can see some tests here:

https://grizzly.dev.java.net/nonav/xref-test/com/sun/grizzly/SuspendableTest.html

Let us know if that doesn't work. Your scenario is quite common and I
can certainly help improving the SuspendableFilter to makes it work for
you :-)

A+

-- Jeanfrancois



>
> Thanks in advance,
> Vishnu
>
>
> --
> Vishnuvardhan Piskalaramesh
> Sun's Open ESB Community (http://open-esb.org)
>