Synchronous Mutliplexing in netty

Rahul Patil rpatil at fusionops.com
Tue Jul 14 01:59:30 EDT 2009


Hi Trustin,
Thanks for the prompt reply.
To put in detail, what we are looking for is as follows:
We have multiple NIO clients which keeps a persistent connection to a single
NIO server.
The server sends commands to these clients to process requests, so in this
case it’s the client which does the work while the server is waiting for the
response.
We want to have all these requests from server to a particular client to be
blocking calls, i.e. synchronous.
Besides, there could be multiple simultaneous requests (different commands)
coming from the server to the same client over the same cannel.
Since we have single handler instance for all these requests (being single
pipeline for a single client-server channel) my concern is about the
blocking queue.
As per my following code, I need to keep taking/offering to the queue this I
find the response which interests me.
My fear is, this will cause an unnecessary multithreading load as each time
I call take as it will notify all the waiting threads.
I am sorry if I am wrong in making the above assumption as I am not much
familiar with multithreading.
If any calling thread dies for some reason, the object in the queue won't be
taken out and will stay there forever.
So essentially, we are looking for some mechanism where we can have multiple
pipelines per channel (or multiple local channels per physical channel) so
that we will have only one object in the queue to make that particular
pipeline synchronous.
But I am not sure how to implement the LocalChannel and how to achieve
multiplexing by it.
I am referring to the post
http://www.jboss.org/netty/community.html#nabble-td2986237 by Fredric
Bregier and our requirement is quite similar to his.
Looking forward to find a resolution to our problem with your valuable
inputs and help.
Regards
Rahul

-----Original Message-----
From: netty-users-bounces at lists.jboss.org
[mailto:netty-users-bounces at lists.jboss.org] On Behalf Of "??? (Trustin
Lee)"
Sent: Monday, July 13, 2009 10:31 PM
To: Netty -Users List
Subject: Re: Synchronous Mutliplexing in netty

Hi Rahul,

I'm not sure what exactly 'synchronous multiplexed calls' mean in this
context.  Could you elaborate with me on what exactly you are trying to
achieve?

Thanks,
Trustin

On 07/14/2009 01:17 PM, Rahul Patil wrote:
> Hi All,
> After evaluating few NIO frameworks we settled on netty owing to its
> flexible and comprehensive architechture. Now I am struggling with a way
> to
> use netty for synchronous mulitiplexed calls. Following the factorial
> example I have been able to address the synchronous part using the
> following
> code:
> public Message getMessage(long workID)
> 	{
> 		while (true)
> 		{
> 			try
> 			{
> 				Message am = queue.take();
> 				if(am.getWorkID() == workID){
> 					return am;
> 				}
> 				else
> 				{
> 					queue.offer(am);
> 				}
> 			}
> 			catch (InterruptedException e)
> 			{
> 				// Ignore.
> 			}
> 		}
> 	}
> I cannot do a peek as the queue can contain more objects so I need to use
> take and offer.
> What essentially follows then is to make it multiplexed as we need to make
> multiple calls over the same channel to avoid the overhead of using
> blocking
> queue.
> I looked at some other pose in this forum and came across LocalChannel.
> However, I am not clear about the rationale behind it and not sure how it
> can be used for multiplexing.
> I ran into xsockets while searching for multiplexing and wondered why this
> feature is lacking in netty.
> Considering the benefits of netty I don't want to switch to xsocket but I
> am
> stuck with this issue which is hindering our project.
> Any help in this matter would be highly appreciated.

_______________________________________________
netty-users mailing list
netty-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/netty-users




More information about the netty-users mailing list