You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Vishal_Jain <pi...@gmail.com> on 2007/11/12 10:15:30 UTC

Proxy design query

Hi All,

Am implementing a proxy like system that has 2 connectors (taking on one end
and transferring onto the other).
what i basically do in the MessageReceived routine of connector1 is call the
IoSession.write of connector2 and that in turn invokes the ProtocolDecoder
(yes am using a Protocol filter on both connectors). If am expected to
handle lot of messages on connector1, would a straightforward
IoSesssion.write() be sufficient or its better to have a Queue that would
have all the incoming requests and then i read the requests on a separate
thread and call connector2's IoSession ?

vishal
-- 
View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Proxy design query

Posted by Vishal_Jain <pi...@gmail.com>.
Yes i do buffer the data before processing it. Thanks for your suggestion,
i'll check both of them out. one at a time :)

vishal


elihusmails wrote:
> 
> I don't think I would, although it depends on the protocol and data.
> If it makes sense to buffer up the data, you might want to use a
> protocol encoder/decoder, then take the data and send it.  You can try
> with and without the queueing, but I bet you find better performance
> with not queueing.
> 
> 
> 
> On Nov 12, 2007 11:40 PM, Vishal_Jain <pi...@gmail.com> wrote:
>>
>> actually i create a new connection on connector2 when i need to send
>> something.
>> (i create a new instance of a class that would handle the connection for
>> connector2 .. which invokes connect() in its constructor; and when it
>> receives the response it closes the session)
>> So you think its not necessary to use any queuing ?
>>
>>
>>
>> elihusmails wrote:
>> >
>> > So you have data coming in on connector 1 and going out connector 2,
>> > do you want connector 2 to always be the same instance?  If so, then
>> > you might need some type of queue in order to use the same connection.
>> >  Otherwise, I am not sure why you would need a queue.
>> >
>> >
>> >
>> > On Nov 12, 2007 11:23 PM, Vishal_Jain <pi...@gmail.com> wrote:
>> >>
>> >> Yes i did take a look at the proxy example and what i implemented is
>> also
>> >> similar to that.
>> >> I have the following understanding of how Mina handles the request,
>> >> please
>> >> correct me if am wrong.
>> >> The execution for each new message coming on one connector till it is
>> >> written onto the other connector happens in a single thread. (i tried
>> >> printing the name of the thread in all these routines and noticed same
>> >> name). and if another message comes during this period, another thread
>> is
>> >> being created.
>> >>
>> >> vishal
>> >>
>> >>
>> >>
>> >> elihusmails wrote:
>> >> >
>> >> > Did you take a look at the proxy example?  I this is may assist you
>> in
>> >> > developing a solution.
>> >> >
>> >> > --Mark
>> >> >
>> >> > On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
>> >> >>
>> >> >> Hi All,
>> >> >>
>> >> >> Am implementing a proxy like system that has 2 connectors (taking
>> on
>> >> one
>> >> >> end
>> >> >> and transferring onto the other).
>> >> >> what i basically do in the MessageReceived routine of connector1 is
>> >> call
>> >> >> the
>> >> >> IoSession.write of connector2 and that in turn invokes the
>> >> >> ProtocolDecoder
>> >> >> (yes am using a Protocol filter on both connectors). If am expected
>> to
>> >> >> handle lot of messages on connector1, would a straightforward
>> >> >> IoSesssion.write() be sufficient or its better to have a Queue that
>> >> would
>> >> >> have all the incoming requests and then i read the requests on a
>> >> separate
>> >> >> thread and call connector2's IoSession ?
>> >> >>
>> >> >> vishal
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
>> >> >> Sent from the Apache MINA Support Forum mailing list archive at
>> >> >> Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > --------------------------------
>> >> > The adjuration to be "normal" seems shockingly repellent to me; I
>> see
>> >> > neither hope nor comfort in sinking to that low level. I think it is
>> >> > ignorance that makes people think of abnormality only with horror
>> and
>> >> > allows them to remain undismayed at the proximity of "normal" to
>> >> > average and mediocre. For surely anyone who achieves anything is,
>> >> > essentially, abnormal.
>> >> >      Dr. Karl Menninger
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719606
>> >>
>> >> Sent from the Apache MINA Support Forum mailing list archive at
>> >> Nabble.com.
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > --------------------------------
>> > The adjuration to be "normal" seems shockingly repellent to me; I see
>> > neither hope nor comfort in sinking to that low level. I think it is
>> > ignorance that makes people think of abnormality only with horror and
>> > allows them to remain undismayed at the proximity of "normal" to
>> > average and mediocre. For surely anyone who achieves anything is,
>> > essentially, abnormal.
>> >      Dr. Karl Menninger
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719706
>>
>> Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --------------------------------
> The adjuration to be "normal" seems shockingly repellent to me; I see
> neither hope nor comfort in sinking to that low level. I think it is
> ignorance that makes people think of abnormality only with horror and
> allows them to remain undismayed at the proximity of "normal" to
> average and mediocre. For surely anyone who achieves anything is,
> essentially, abnormal.
>      Dr. Karl Menninger
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719886
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Proxy design query

Posted by Mark <el...@gmail.com>.
I don't think I would, although it depends on the protocol and data.
If it makes sense to buffer up the data, you might want to use a
protocol encoder/decoder, then take the data and send it.  You can try
with and without the queueing, but I bet you find better performance
with not queueing.



On Nov 12, 2007 11:40 PM, Vishal_Jain <pi...@gmail.com> wrote:
>
> actually i create a new connection on connector2 when i need to send
> something.
> (i create a new instance of a class that would handle the connection for
> connector2 .. which invokes connect() in its constructor; and when it
> receives the response it closes the session)
> So you think its not necessary to use any queuing ?
>
>
>
> elihusmails wrote:
> >
> > So you have data coming in on connector 1 and going out connector 2,
> > do you want connector 2 to always be the same instance?  If so, then
> > you might need some type of queue in order to use the same connection.
> >  Otherwise, I am not sure why you would need a queue.
> >
> >
> >
> > On Nov 12, 2007 11:23 PM, Vishal_Jain <pi...@gmail.com> wrote:
> >>
> >> Yes i did take a look at the proxy example and what i implemented is also
> >> similar to that.
> >> I have the following understanding of how Mina handles the request,
> >> please
> >> correct me if am wrong.
> >> The execution for each new message coming on one connector till it is
> >> written onto the other connector happens in a single thread. (i tried
> >> printing the name of the thread in all these routines and noticed same
> >> name). and if another message comes during this period, another thread is
> >> being created.
> >>
> >> vishal
> >>
> >>
> >>
> >> elihusmails wrote:
> >> >
> >> > Did you take a look at the proxy example?  I this is may assist you in
> >> > developing a solution.
> >> >
> >> > --Mark
> >> >
> >> > On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
> >> >>
> >> >> Hi All,
> >> >>
> >> >> Am implementing a proxy like system that has 2 connectors (taking on
> >> one
> >> >> end
> >> >> and transferring onto the other).
> >> >> what i basically do in the MessageReceived routine of connector1 is
> >> call
> >> >> the
> >> >> IoSession.write of connector2 and that in turn invokes the
> >> >> ProtocolDecoder
> >> >> (yes am using a Protocol filter on both connectors). If am expected to
> >> >> handle lot of messages on connector1, would a straightforward
> >> >> IoSesssion.write() be sufficient or its better to have a Queue that
> >> would
> >> >> have all the incoming requests and then i read the requests on a
> >> separate
> >> >> thread and call connector2's IoSession ?
> >> >>
> >> >> vishal
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
> >> >> Sent from the Apache MINA Support Forum mailing list archive at
> >> >> Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > --------------------------------
> >> > The adjuration to be "normal" seems shockingly repellent to me; I see
> >> > neither hope nor comfort in sinking to that low level. I think it is
> >> > ignorance that makes people think of abnormality only with horror and
> >> > allows them to remain undismayed at the proximity of "normal" to
> >> > average and mediocre. For surely anyone who achieves anything is,
> >> > essentially, abnormal.
> >> >      Dr. Karl Menninger
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719606
> >>
> >> Sent from the Apache MINA Support Forum mailing list archive at
> >> Nabble.com.
> >>
> >>
> >
> >
> >
> > --
> > --------------------------------
> > The adjuration to be "normal" seems shockingly repellent to me; I see
> > neither hope nor comfort in sinking to that low level. I think it is
> > ignorance that makes people think of abnormality only with horror and
> > allows them to remain undismayed at the proximity of "normal" to
> > average and mediocre. For surely anyone who achieves anything is,
> > essentially, abnormal.
> >      Dr. Karl Menninger
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719706
>
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>



-- 
--------------------------------
The adjuration to be "normal" seems shockingly repellent to me; I see
neither hope nor comfort in sinking to that low level. I think it is
ignorance that makes people think of abnormality only with horror and
allows them to remain undismayed at the proximity of "normal" to
average and mediocre. For surely anyone who achieves anything is,
essentially, abnormal.
     Dr. Karl Menninger

Re: Proxy design query

Posted by Vishal_Jain <pi...@gmail.com>.
actually i create a new connection on connector2 when i need to send
something.
(i create a new instance of a class that would handle the connection for
connector2 .. which invokes connect() in its constructor; and when it
receives the response it closes the session)
So you think its not necessary to use any queuing ?


elihusmails wrote:
> 
> So you have data coming in on connector 1 and going out connector 2,
> do you want connector 2 to always be the same instance?  If so, then
> you might need some type of queue in order to use the same connection.
>  Otherwise, I am not sure why you would need a queue.
> 
> 
> 
> On Nov 12, 2007 11:23 PM, Vishal_Jain <pi...@gmail.com> wrote:
>>
>> Yes i did take a look at the proxy example and what i implemented is also
>> similar to that.
>> I have the following understanding of how Mina handles the request,
>> please
>> correct me if am wrong.
>> The execution for each new message coming on one connector till it is
>> written onto the other connector happens in a single thread. (i tried
>> printing the name of the thread in all these routines and noticed same
>> name). and if another message comes during this period, another thread is
>> being created.
>>
>> vishal
>>
>>
>>
>> elihusmails wrote:
>> >
>> > Did you take a look at the proxy example?  I this is may assist you in
>> > developing a solution.
>> >
>> > --Mark
>> >
>> > On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
>> >>
>> >> Hi All,
>> >>
>> >> Am implementing a proxy like system that has 2 connectors (taking on
>> one
>> >> end
>> >> and transferring onto the other).
>> >> what i basically do in the MessageReceived routine of connector1 is
>> call
>> >> the
>> >> IoSession.write of connector2 and that in turn invokes the
>> >> ProtocolDecoder
>> >> (yes am using a Protocol filter on both connectors). If am expected to
>> >> handle lot of messages on connector1, would a straightforward
>> >> IoSesssion.write() be sufficient or its better to have a Queue that
>> would
>> >> have all the incoming requests and then i read the requests on a
>> separate
>> >> thread and call connector2's IoSession ?
>> >>
>> >> vishal
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
>> >> Sent from the Apache MINA Support Forum mailing list archive at
>> >> Nabble.com.
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > --------------------------------
>> > The adjuration to be "normal" seems shockingly repellent to me; I see
>> > neither hope nor comfort in sinking to that low level. I think it is
>> > ignorance that makes people think of abnormality only with horror and
>> > allows them to remain undismayed at the proximity of "normal" to
>> > average and mediocre. For surely anyone who achieves anything is,
>> > essentially, abnormal.
>> >      Dr. Karl Menninger
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719606
>>
>> Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --------------------------------
> The adjuration to be "normal" seems shockingly repellent to me; I see
> neither hope nor comfort in sinking to that low level. I think it is
> ignorance that makes people think of abnormality only with horror and
> allows them to remain undismayed at the proximity of "normal" to
> average and mediocre. For surely anyone who achieves anything is,
> essentially, abnormal.
>      Dr. Karl Menninger
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719706
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Proxy design query

Posted by Mark <el...@gmail.com>.
So you have data coming in on connector 1 and going out connector 2,
do you want connector 2 to always be the same instance?  If so, then
you might need some type of queue in order to use the same connection.
 Otherwise, I am not sure why you would need a queue.



On Nov 12, 2007 11:23 PM, Vishal_Jain <pi...@gmail.com> wrote:
>
> Yes i did take a look at the proxy example and what i implemented is also
> similar to that.
> I have the following understanding of how Mina handles the request, please
> correct me if am wrong.
> The execution for each new message coming on one connector till it is
> written onto the other connector happens in a single thread. (i tried
> printing the name of the thread in all these routines and noticed same
> name). and if another message comes during this period, another thread is
> being created.
>
> vishal
>
>
>
> elihusmails wrote:
> >
> > Did you take a look at the proxy example?  I this is may assist you in
> > developing a solution.
> >
> > --Mark
> >
> > On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
> >>
> >> Hi All,
> >>
> >> Am implementing a proxy like system that has 2 connectors (taking on one
> >> end
> >> and transferring onto the other).
> >> what i basically do in the MessageReceived routine of connector1 is call
> >> the
> >> IoSession.write of connector2 and that in turn invokes the
> >> ProtocolDecoder
> >> (yes am using a Protocol filter on both connectors). If am expected to
> >> handle lot of messages on connector1, would a straightforward
> >> IoSesssion.write() be sufficient or its better to have a Queue that would
> >> have all the incoming requests and then i read the requests on a separate
> >> thread and call connector2's IoSession ?
> >>
> >> vishal
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
> >> Sent from the Apache MINA Support Forum mailing list archive at
> >> Nabble.com.
> >>
> >>
> >
> >
> >
> > --
> > --------------------------------
> > The adjuration to be "normal" seems shockingly repellent to me; I see
> > neither hope nor comfort in sinking to that low level. I think it is
> > ignorance that makes people think of abnormality only with horror and
> > allows them to remain undismayed at the proximity of "normal" to
> > average and mediocre. For surely anyone who achieves anything is,
> > essentially, abnormal.
> >      Dr. Karl Menninger
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719606
>
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>



-- 
--------------------------------
The adjuration to be "normal" seems shockingly repellent to me; I see
neither hope nor comfort in sinking to that low level. I think it is
ignorance that makes people think of abnormality only with horror and
allows them to remain undismayed at the proximity of "normal" to
average and mediocre. For surely anyone who achieves anything is,
essentially, abnormal.
     Dr. Karl Menninger

Re: Proxy design query

Posted by Vishal_Jain <pi...@gmail.com>.
Yes i did take a look at the proxy example and what i implemented is also
similar to that.
I have the following understanding of how Mina handles the request, please
correct me if am wrong.
The execution for each new message coming on one connector till it is
written onto the other connector happens in a single thread. (i tried
printing the name of the thread in all these routines and noticed same
name). and if another message comes during this period, another thread is
being created.

vishal
 

elihusmails wrote:
> 
> Did you take a look at the proxy example?  I this is may assist you in
> developing a solution.
> 
> --Mark
> 
> On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
>>
>> Hi All,
>>
>> Am implementing a proxy like system that has 2 connectors (taking on one
>> end
>> and transferring onto the other).
>> what i basically do in the MessageReceived routine of connector1 is call
>> the
>> IoSession.write of connector2 and that in turn invokes the
>> ProtocolDecoder
>> (yes am using a Protocol filter on both connectors). If am expected to
>> handle lot of messages on connector1, would a straightforward
>> IoSesssion.write() be sufficient or its better to have a Queue that would
>> have all the incoming requests and then i read the requests on a separate
>> thread and call connector2's IoSession ?
>>
>> vishal
>> --
>> View this message in context:
>> http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
>> Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --------------------------------
> The adjuration to be "normal" seems shockingly repellent to me; I see
> neither hope nor comfort in sinking to that low level. I think it is
> ignorance that makes people think of abnormality only with horror and
> allows them to remain undismayed at the proximity of "normal" to
> average and mediocre. For surely anyone who achieves anything is,
> essentially, abnormal.
>      Dr. Karl Menninger
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13719606
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Proxy design query

Posted by Mark <el...@gmail.com>.
Did you take a look at the proxy example?  I this is may assist you in
developing a solution.

--Mark

On Nov 12, 2007 4:15 AM, Vishal_Jain <pi...@gmail.com> wrote:
>
> Hi All,
>
> Am implementing a proxy like system that has 2 connectors (taking on one end
> and transferring onto the other).
> what i basically do in the MessageReceived routine of connector1 is call the
> IoSession.write of connector2 and that in turn invokes the ProtocolDecoder
> (yes am using a Protocol filter on both connectors). If am expected to
> handle lot of messages on connector1, would a straightforward
> IoSesssion.write() be sufficient or its better to have a Queue that would
> have all the incoming requests and then i read the requests on a separate
> thread and call connector2's IoSession ?
>
> vishal
> --
> View this message in context: http://www.nabble.com/Proxy-design-query-tf4789817s16868.html#a13702157
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>



-- 
--------------------------------
The adjuration to be "normal" seems shockingly repellent to me; I see
neither hope nor comfort in sinking to that low level. I think it is
ignorance that makes people think of abnormality only with horror and
allows them to remain undismayed at the proximity of "normal" to
average and mediocre. For surely anyone who achieves anything is,
essentially, abnormal.
     Dr. Karl Menninger