On Thu, Feb 26, 2009 at 06:07:11PM +0530, Srinivas Naresh Bhimisetty wrote:
> Paul Sandoz wrote:
>>
>> On Feb 26, 2009, at 1:10 PM, Srinivas Naresh Bhimisetty wrote:
>>
>>> Hi,
>>>
>>> one of my colleagues asked me this question today.
>>> He wants to create a RESTful Web Service using Jersey and deploy it in a
>>> clustered environment.
>>
>> If you conform to the REST stateless constraint then you do not require
>> clustering. Strictly speaking the application is not that RESTful if it
>> relies on session state.
> True. But he just wants to use it just for some demonstration purpose. The
> main goal was to demonstrate clustering, he wanted to use the RESTful web
> service in the demo, if possible.
In this case (a demonstration), i would +1 avoid using sessions, and rather
model sessions by web resources states.
Because then you should only need a http load balancer at front-end
and a HA database at back-end. Without a need to bother with
things like session affinity.
~Jakub
>
> -Naresh
>>
>> Say you have a database then rather than manage the high availability of
>> types of state, session and that in the database, you only need to manage
>> the latter. You can transform what would previously considered to be
>> session state into resource state that is stored in the database and
>> accessible via a URL.
>>
>>
>>> In order to test this, he said he wants to set some information in the
>>> service and put in the session, and get one of the nodes on the cluster
>>> down, and be able to access it from the instance running on another node.
>>> I thought @PerSession might be helpful, but looks like a new instance of
>>> the application would be running on each node.
>>
>> An instance of the application *has* to be running at each node for it to
>> be clustered. The session state is shared between the applications.
>>
>> @PerSession should work. However, i don't recommend you use that unless
>> you really have to.
>>
>> When an instance of a @PerSession resource class is required it will first
>> ask if there is an instance in the session attributes. If there is then
>> that will be used. Otherwise a new instance will be created and stored in
>> the session. The instance is only stored in the session once, so there are
>> probably some restrictions on if you change the state of the resource.
>>
>> Paul.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>