passing data between ChannelHandlers
Norman Maurer
norman.maurer at googlemail.com
Tue Oct 25 02:28:50 EDT 2011
Hi there,
can you give some more details and what you try to do ?
Bye,
Norman
2011/10/25 Matt DeLuco <list_usr at spacebox.net>:
> Thank you, Norman!
> I have to say though, this all seems like a very roundabout way of keeping
> track of session data for a Channel.
> Is there any interest in adding a session interface to HttpRequest,
> something like javax.servlet.http.HttpSession found in
> javax.servlet.http.HttpRequest?
> I thought if there was an interface one could implement the storage
> mechanism - file/database/memcached, etc.
> MD
>
> On Mon, Oct 24, 2011 at 6:16 AM, Norman Maurer
> <norman.maurer at googlemail.com> wrote:
>>
>> Hi there,
>>
>> just to follow up. I committed some code to handle the removal without
>> user interaction:
>>
>>
>> https://issues.jboss.org/browse/NETTY-447?page=com.atlassian.jirafisheyeplugin:fisheye-issuepanel#issue-tabs
>>
>> So it will be in the next release...
>>
>> Bye
>> Norman
>>
>> 2011/10/24 Norman Maurer <norman.maurer at googlemail.com>:
>> > Hi Matt,
>> >
>> > comments inline..
>> >
>> > 2011/10/24 Matt DeLuco <list_usr at spacebox.net>:
>> >> I found what I was looking for - a brief example of ChannelLocal is
>> >> found in
>> >> the ChannelHandler documentation (ps: it might be worth repeating in
>> >> the
>> >> ChannelLocal docs..) But now I'm wondering:
>> >> The example shows a DataServerState class - where would that class be
>> >> instantiated such that all handlers have access to it? I thought I
>> >> might
>> >> instantiate it in my server startup code, pass it to the
>> >> ChannelPipelineFactory where I could pass it on to the constructor of
>> >> each
>> >> ChannelHandler. Is there another way?
>> >
>> > I think thats the easiest way and should work very well.
>> >
>> >> Also, at some point before the Channel closes would I have to be sure
>> >> to
>> >> remove any ChannelLocal variable references? That is, ChannelLocals
>> >> map
>> >> values to Channels, so would I have to be sure to remove each reference
>> >> so
>> >> values to closed Channels don't pile up, creating a memory leak? If
>> >> so,
>> >> how/where could I attach an event handler to a Channel to do this?
>> >> Would I
>> >> have to do this in a ChannelHandler (I don't like that idea, because
>> >> which
>> >> ChannelHandler do I put it in?) or create some kind of custom
>> >> ChannelFactory?
>> >
>> > Just add an SimpleUpstreamChannelHandler and override the
>> > channelClosed(..) method. There you can remove it.
>> > I think it would also be nice to allow the ChannelLocal to cleanup it
>> > self by register and ChannelListener to it that takes care of the
>> > remove and so prevent the leak. I will open a jira issue for it and
>> > implement it.
>> >
>> >
>> >> Thanks.
>> >> MD
>> >>
>> >> On Fri, Oct 21, 2011 at 3:36 AM, Norman Maurer
>> >> <norman.maurer at googlemail.com> wrote:
>> >>>
>> >>> I was using it before in a project but remoted it in favor of
>> >>> ChannelHandlerContext.setAttachment(..).
>> >>>
>> >>> But it worked quited fine for me. You can see the old code here:
>> >>>
>> >>>
>> >>>
>> >>> http://svn.apache.org/viewvc/james/protocols/tags/protocols-1.5/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelUpstreamHandler.java?view=markup
>> >>>
>> >>> Bye,
>> >>> Norman
>> >>>
>> >>> Ps: What does not work for you ?
>> >>>
>> >>> 2011/10/21 Matt DeLuco <list_usr at spacebox.net>:
>> >>> > Where can I find some examples of ChannelLocal in use?
>> >>> > I'm not getting the results I expect, but I don't think I'm using it
>> >>> > correctly either.
>> >>> > MD
>> >>> >
>> >>> > On Sun, Oct 16, 2011 at 7:14 AM, Norman Maurer
>> >>> > <norman.maurer at googlemail.com> wrote:
>> >>> >>
>> >>> >> You can set anything you want as attachment. But it's only visible
>> >>> >> in
>> >>> >> the same handler....
>> >>> >>
>> >>> >> If you want to share stuff between handler you should checkout
>> >>> >> ChannelLocal
>> >>> >>
>> >>> >> Bye
>> >>> >> Norman
>> >>> >> 2011/10/16, Matt DeLuco <list_usr at spacebox.net>:
>> >>> >> > Before composing this message I had noticed
>> >>> >> > ChannelHandlerContext.setAttachment(Object) and getAttachment().
>> >>> >> > But
>> >>> >> > for some reason I came to the conclusion that it wasn't intended
>> >>> >> > for
>> >>> >> > what I want to do.
>> >>> >> >
>> >>> >> > I came to that conclusion in part because I found it strange that
>> >>> >> > it's
>> >>> >> > only possible to set one attachment, rather than being able to
>> >>> >> > attach
>> >>> >> > a set (or map) of objects. Could I just attach a map to the
>> >>> >> > context
>> >>> >> > and store whatever I want in that map, to pass objects between
>> >>> >> > ChannelHandlers?
>> >>> >> >
>> >>> >> > MD
>> >>> >> >
>> >>> >> >
>> >>> >> > On Sat, Oct 15, 2011 at 9:42 PM, Matt DeLuco
>> >>> >> > <list_usr at spacebox.net>
>> >>> >> > wrote:
>> >>> >> >> Is it possible to pass data between ChannelHandlers, or store
>> >>> >> >> data
>> >>> >> >> somewhere that the handlers in a specific pipeline/channel can
>> >>> >> >> access
>> >>> >> >> throughout the lifetime of the request?
>> >>> >> >>
>> >>> >> >> For example, I have my own class for dealing with http cookies,
>> >>> >> >> "CookieMap". I'd like to have a SimpleChannelHandler that
>> >>> >> >> creates a
>> >>> >> >> CookieMap to be used by handlers further upstream, and then sets
>> >>> >> >> the
>> >>> >> >> cookies in the CookieMap on the response on their way back
>> >>> >> >> downstream.
>> >>> >> >>
>> >>> >> >> MD
>> >>> >> >>
>> >>> >> >
>> >>> >> > _______________________________________________
>> >>> >> > netty-users mailing list
>> >>> >> > netty-users at lists.jboss.org
>> >>> >> > https://lists.jboss.org/mailman/listinfo/netty-users
>> >>> >> >
>> >>> >> _______________________________________________
>> >>> >> netty-users mailing list
>> >>> >> netty-users at lists.jboss.org
>> >>> >> https://lists.jboss.org/mailman/listinfo/netty-users
>> >>> >
>> >>> >
>> >
>> > Bye,
>> > Norman
>> >
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
> _______________________________________________
> 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