Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

How to create a stateful remote service

I'm reading about Executor Based Remoting: http://wiki.gigaspaces.com/wiki/displ...

It seems that this is purely a stateless service.

What I want is a stateful service, sort of like a EJB SFSB.

Is that even possible with XAP?

asked 2014-03-31 11:40:36 -0500

Steve McCarthy gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Anything is possible with XAP! ;-)

If I understand you correctly, you would like to provide a service that maintains some sort of state across invocations of the methods it exposes.

There are three approaches to implement what you want:

1) Store state in the service and use the Remote Routing Handler (documented on the same page you reference) to ensure that you get the same service instance on subsequent method invocations

2) Store state in the space and use the Remote Routing Handler to ensure that you get the same service instance on subsequent method invocations

3) Store state in the space, return a token from the first method invocation, and use that token on subsequent calls to allow the service to retrieve the appropriate state

With XAP, state is generally stored in the space in order to provide resiliency in the case of failover. You can store state in the service itself, but it will be lost if that node goes down because of a hardware failure or similar problem. If you don't need separate states for each client of the service, the second approach is your most reliable option.

answered 2014-03-31 13:57:16 -0500

Patrick gravatar image
edit flag offensive delete link more

Comments

I need state to be stored on a per client basis.

So I would need to generate a session ID and return that to the client which they would use on subsequent requests for the same session.

Unfortunately this is not ideal since you have to also deal with session timeouts and cleanup. If you didn't session data would continue to grow until your out of memory.

I just wish XAP had a better way of dealing with this.

Steve McCarthy gravatar imageSteve McCarthy ( 2014-03-31 14:20:20 -0500 )edit

You can set a lease time for the state objects. They will disappear from the space when the lease expires.

Patrick gravatar imagePatrick ( 2014-03-31 15:09:05 -0500 )edit

I guess it'll work though sort of clunky. Perhaps returning a UUID for a session ID would work.

Steve McCarthy gravatar imageSteve McCarthy ( 2014-03-31 17:57:26 -0500 )edit

This is a fairly common use case for XAP. I'd be happy to write up an example over the next couple of weeks. Please email me (patrick dot may at gigaspaces dot com) to discuss your requirements if there are details that you'd prefer not to share in public.

Patrick gravatar imagePatrick ( 2014-03-31 18:04:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-03-31 11:40:36 -0500

Seen: 1,219 times

Last updated: Mar 31 '14