You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Dejan Bosanac <de...@ttmsolutions.com> on 2008/10/01 16:29:42 UTC

Re: Passing in Session ID from client for REST based Messaging

Hi,

you cannot force servlet to create a session with the id you provided. I
agree that we have to support sessionless consuming possible. I've
created a Jira issue for this

https://issues.apache.org/activemq/browse/AMQ-1960

Cheers

-- 
Dejan Bosanac


http://www.ttmsolutions.com - get a free ActiveMQ user guide

ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net


OneWhoMikes wrote:
> I want to configure ActiveMQ to look for a session id in the URL from a
> client REST request.  This would allow for the client to pass along it's own
> ID, instead of the server generating one and setting a cookie.
>
> I found the following posts:
> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/
> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/ 
> http://docs.codehaus.org/display/JETTY/SessionIds
> http://docs.codehaus.org/display/JETTY/SessionIds 
>
> Using the above references as a guide, I created the following jetty-web.xml
> file in my webapp's WEB-INF directory:
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
> "http://jetty.mortbay.org/configure.dtd">
> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>     <Get name="sessionHandler">
>         <Get name="sessionManager">
>             <Set name="usingCookies" type="boolean">false</Set>
>         </Get>
>     </Get>
>
>     <Set name="initParams">
>         <Map>
>             <Entry>
>                <Item>org.mortbay.jetty.servlet.SessionURL</Item>
>                <Item>xsessionid</Item>
>             </Entry>
>         </Map>
>      </Set>
> </Configure>
>
>
> This configuration does disable the cookies, but a new session is being
> created for every request - regardless of what I pass in as the "xsessionid"
> parameter with the request.
>
>
> Any help would be greatly appreciated.
>
>
> Thanks,
>
> Mike
>
>   



Re: Passing in Session ID from client for REST based Messaging

Posted by James Strachan <ja...@gmail.com>.
2008/10/2 Dejan Bosanac <de...@ttmsolutions.com>:
> Cool. Thanks for the info :)

BTW if anyone wants a head start in hacking up an activemq-rest
module, there's a Camel one I've started hacking together (though its
very early days...)
https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-rest/

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Passing in Session ID from client for REST based Messaging

Posted by Dejan Bosanac <de...@ttmsolutions.com>.
Cool. Thanks for the info :)

-- 
Dejan Bosanac


http://www.ttmsolutions.com - get a free ActiveMQ user guide

ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net



James Strachan wrote:
> Yeah; its way more mature with a much more active community behind it
> and has some neat extra features (WADL, implicit views, client side
> API etc). Though being JAX-RS it could technically work with any
> provider.
>
>   



Re: Passing in Session ID from client for REST based Messaging

Posted by James Strachan <ja...@gmail.com>.
2008/10/2 Dejan Bosanac <de...@ttmsolutions.com>:
> I have this on my wish list for quite some time, but never managed to
> find time to do it :(
>
> I originally looked at other design protocol you've made
>
> http://activemq.apache.org/rest-protocols.html
>
> but this one is much more complete.
>
> This RESTful protocol you defined for queues could be implemented for
> topics as well (making it universal API) or am I missing something?
>
> BTW. Do you think Jersey is the better route than CXF JAX-RS implementation?

Yeah; its way more mature with a much more active community behind it
and has some neat extra features (WADL, implicit views, client side
API etc). Though being JAX-RS it could technically work with any
provider.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Passing in Session ID from client for REST based Messaging

Posted by Dejan Bosanac <de...@ttmsolutions.com>.
I have this on my wish list for quite some time, but never managed to
find time to do it :(

I originally looked at other design protocol you've made

http://activemq.apache.org/rest-protocols.html

but this one is much more complete.

This RESTful protocol you defined for queues could be implemented for
topics as well (making it universal API) or am I missing something?

BTW. Do you think Jersey is the better route than CXF JAX-RS implementation?

Cheers

-- 
Dejan Bosanac


http://www.ttmsolutions.com - get a free ActiveMQ user guide

ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net



James Strachan wrote:
> Agreed. One day it'd be great to support a true hi-REST API for
> ActiveMQ along these lines...
>
> http://activemq.apache.org/restful-queue.html
>
> then folks could RESTfully interact in a reliable manner with ActiveMQ
> in a clean hi-rest way without requiring cookies etc.
>
> If anyone fancies taking a stab at this; please use JAX-RS which rocks
> (and Jersey seems the best implementation around).
>
>   



Re: Passing in Session ID from client for REST based Messaging

Posted by James Strachan <ja...@gmail.com>.
2008/10/2 Dejan Bosanac <de...@ttmsolutions.com>:
> The first time you access some web app (REST servlet in this case), the
> session will be created by the server and a unique id will be associated
> to it. You'll get that info as a jsessionid (usually in a cookie) in a
> response to your request. For subsequent calls you have an option to
> pass that session id either in a cookie or as a URL parameter, but first
> you have to extract it.
>
> That's how session works and there is nothing we can do about it. So I
> think it would be easier for clients not supporting cookies to
> specifically define a consumer id and avoid using sessions at all.

Agreed. One day it'd be great to support a true hi-REST API for
ActiveMQ along these lines...

http://activemq.apache.org/restful-queue.html

then folks could RESTfully interact in a reliable manner with ActiveMQ
in a clean hi-rest way without requiring cookies etc.

If anyone fancies taking a stab at this; please use JAX-RS which rocks
(and Jersey seems the best implementation around).

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Passing in Session ID from client for REST based Messaging

Posted by Dejan Bosanac <de...@ttmsolutions.com>.
The first time you access some web app (REST servlet in this case), the
session will be created by the server and a unique id will be associated
to it. You'll get that info as a jsessionid (usually in a cookie) in a
response to your request. For subsequent calls you have an option to
pass that session id either in a cookie or as a URL parameter, but first
you have to extract it.

That's how session works and there is nothing we can do about it. So I
think it would be easier for clients not supporting cookies to
specifically define a consumer id and avoid using sessions at all.

Cheers

-- 
Dejan Bosanac


http://www.ttmsolutions.com - get a free ActiveMQ user guide

ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net




OneWhoMikes wrote:
> Thanks for the info.
>
> However, what I'm proposing is not "sessionless" - I just want to be able to
> specify the session id along with the request.
>
> --Mike
>
>
>
> Dejan Bosanac-3 wrote:
>   
>> Hi,
>>
>> you cannot force servlet to create a session with the id you provided. I
>> agree that we have to support sessionless consuming possible. I've
>> created a Jira issue for this
>>
>> https://issues.apache.org/activemq/browse/AMQ-1960
>>
>> Cheers
>>
>> -- 
>> Dejan Bosanac
>>
>>
>> http://www.ttmsolutions.com - get a free ActiveMQ user guide
>>
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Scripting in Java - http://www.scriptinginjava.net
>>
>>
>> OneWhoMikes wrote:
>>     
>>> I want to configure ActiveMQ to look for a session id in the URL from a
>>> client REST request.  This would allow for the client to pass along it's
>>> own
>>> ID, instead of the server generating one and setting a cookie.
>>>
>>> I found the following posts:
>>> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/
>>> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/ 
>>> http://docs.codehaus.org/display/JETTY/SessionIds
>>> http://docs.codehaus.org/display/JETTY/SessionIds 
>>>
>>> Using the above references as a guide, I created the following
>>> jetty-web.xml
>>> file in my webapp's WEB-INF directory:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
>>> "http://jetty.mortbay.org/configure.dtd">
>>> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>>>     <Get name="sessionHandler">
>>>         <Get name="sessionManager">
>>>             <Set name="usingCookies" type="boolean">false</Set>
>>>         </Get>
>>>     </Get>
>>>
>>>     <Set name="initParams">
>>>         <Map>
>>>             <Entry>
>>>                <Item>org.mortbay.jetty.servlet.SessionURL</Item>
>>>                <Item>xsessionid</Item>
>>>             </Entry>
>>>         </Map>
>>>      </Set>
>>> </Configure>
>>>
>>>
>>> This configuration does disable the cookies, but a new session is being
>>> created for every request - regardless of what I pass in as the
>>> "xsessionid"
>>> parameter with the request.
>>>
>>>
>>> Any help would be greatly appreciated.
>>>
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>   
>>>       
>>
>>
>>     
>
>   



Re: Passing in Session ID from client for REST based Messaging

Posted by OneWhoMikes <ri...@gmail.com>.
Thanks for the info.

However, what I'm proposing is not "sessionless" - I just want to be able to
specify the session id along with the request.

--Mike



Dejan Bosanac-3 wrote:
> 
> Hi,
> 
> you cannot force servlet to create a session with the id you provided. I
> agree that we have to support sessionless consuming possible. I've
> created a Jira issue for this
> 
> https://issues.apache.org/activemq/browse/AMQ-1960
> 
> Cheers
> 
> -- 
> Dejan Bosanac
> 
> 
> http://www.ttmsolutions.com - get a free ActiveMQ user guide
> 
> ActiveMQ in Action - http://www.manning.com/snyder/
> Scripting in Java - http://www.scriptinginjava.net
> 
> 
> OneWhoMikes wrote:
>> I want to configure ActiveMQ to look for a session id in the URL from a
>> client REST request.  This would allow for the client to pass along it's
>> own
>> ID, instead of the server generating one and setting a cookie.
>>
>> I found the following posts:
>> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/
>> http://www.mojavelinux.com/blog/archives/2006/11/disabling_session_cookies_in_jetty/ 
>> http://docs.codehaus.org/display/JETTY/SessionIds
>> http://docs.codehaus.org/display/JETTY/SessionIds 
>>
>> Using the above references as a guide, I created the following
>> jetty-web.xml
>> file in my webapp's WEB-INF directory:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
>> "http://jetty.mortbay.org/configure.dtd">
>> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>>     <Get name="sessionHandler">
>>         <Get name="sessionManager">
>>             <Set name="usingCookies" type="boolean">false</Set>
>>         </Get>
>>     </Get>
>>
>>     <Set name="initParams">
>>         <Map>
>>             <Entry>
>>                <Item>org.mortbay.jetty.servlet.SessionURL</Item>
>>                <Item>xsessionid</Item>
>>             </Entry>
>>         </Map>
>>      </Set>
>> </Configure>
>>
>>
>> This configuration does disable the cookies, but a new session is being
>> created for every request - regardless of what I pass in as the
>> "xsessionid"
>> parameter with the request.
>>
>>
>> Any help would be greatly appreciated.
>>
>>
>> Thanks,
>>
>> Mike
>>
>>   
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Passing-in-Session-ID-from-client-for-REST-based-Messaging-tp19746620p19763309.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.