Hi Vishnu,
ok thank you very much for your reply.
Now it is very clear what you intend and I think Jeanfrancois put you absolutely on the right track.
So basicly as you wrote you need to extend SuspendableFilter
and do something like:
final Suspendable session=suspend();
new Thread(new Runnable() {
void run() {
final Object result =doBusinessLogic();
session.resumeAndWriteBack(result);
).start();
I think it would be great if SuspendableFilter would have this function.....
Many Greetings
John
-------- Original-Nachricht --------
> Datum: Thu, 03 Jul 2008 18:03:44 +0530
> Von: Vishnuvardhan <Vishnuvardhan.Piskalaramesh_at_Sun.COM>
> An: John ROM <snake-john_at_gmx.de>
> Betreff: Re: Asynchronous Request Processing with TCPIP
> Hi John
>
> By looking at the sample code it looks very complex for me. For that
> matter HL7 is a simple protocol. The HL7 messages are text messages
> wrapped in with start block character, end data character and end block
> character. These characters can be user configurable. For me a
> ReadFilter can do. What I need is a mechanism to associate a request and
> a response. The response will be written from another thread.
>
> Since I am migrating from Apache Mina to Grizzly I am expecting
> something similar to Mina's IoHandlerAdapter which can associate a
> Session with the received message and I can use the session to write the
> response from a different thread.
>
> I need something like your ProtocolWriter.write() which can take a
> sessionId and the context which are associated with the request
> message. I am expecting a simpler way to do this.
>
> I did not go through your code completely. Let me know if I can still
> achieve this with your code.
>
> Thanks
> Vishnu
>
>
> John ROM wrote:
> > Hi Vishnu,
> > I am very interested in your usecase!
> >
> > I do not know anything about HL7 Protocol so I may misunderstand you.
> >
> > Am I right and with "same socket" you just mean "same client-server
> connection"?
> >
> > Maybe you could take a look at
> >
> >
> http://www.nabble.com/-ACTION--Simple-way-to-improve-Grizzly%3A-Gap-submission-td18124343.html#a18181887
> >
> > and
> >
> >
> http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-framework-samples/1.8.1/
> >
> > java -jar grizzly-framework-samples-1.8.1.jar
> >
> > And explain to me maybe why the example does not work for you?
> >
> > In the moment I do not use the SuspendableFilter technic. (because I
> overlooked it so far)
> > But will soon try to plug it in ....
> >
> > Many Greetings
> > p.s:The code is just a pre prerelease (-:
> >
> >
> >
> >
> >
> >
> >
> >> An: users_at_grizzly.dev.java.net
> >> Cc: Nageswara Rao
> >> Betreff: Re: Asynchronous Request Processing with TCPIP
> >>
> >> Hi Jeanfrancois
> >>
> >> Thanks for your help. I looked at the SuspendableFilter. This filter
> >> suspends the execution based on the match of the string received. In my
> >> case, the input can be any HL7 message. I need to suspend after I
> >> receive the HL7 message.
> >>
> >> I need to have something like this:
> >>
> >> class SuspendableFilter
> >>
> >> //inside execute()
> >>
> >> //read the string received
> >> this.suspend();
> >> //continue execution after resuming..
> >>
> >> From some other method.
> >>
> >> suspendableFilter.resume().
> >>
> >> Again, thank you very much for considering my request.
> >>
> >> Vishnu
> >>
> >>
> >> Jeanfrancois Arcand wrote:
> >>
> >>> 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)
> >>>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> >>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
> >>>
> >>>
> >>>
> >> --
> >> Vishnuvardhan Piskalaramesh
> >> Sun's Open ESB Community (http://open-esb.org)
> >>
> >
> >
>
>
> --
> Vishnuvardhan Piskalaramesh
> Sun's Open ESB Community (http://open-esb.org)
>
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger