I've a webservice using Spring Session and Redis. When I call every webservice operation a session object is materialized from redis and when the operation finishes this object is saved to the redis server. The problem arises when I want to change the values of the session and the same session has multiple operations running concurrently. If the operation that changes the session is not the latest that finishes the execution changes are lost (Every operation saves its own session). Is possible avoid this problem indicating to the webservice that only can save the session object some special operations and not all the operations?
The code that works wrong for me is like that:
@Component
@Scope(value=WebApplicationContext.SCOPE_SESSION,
proxyMode=ScopedProxyMode.TARGET_CLASS)
public class SessionInfo implements Serializable
{
private String sellerName;
public String getSellerName() {
return (sellerName==null) ? "" : sellerName; }
public void setSellerName(String sellerName) {
this.sellerName = sellerName;}
}
If I call the operation A() and it changes the seller name calling setSellerName() and this call is during the execution of another operation called B() that loads SessionInfo but not changes it and A() finishes before B() I lost the seller name changes becaure when B() finishes it overwrites the value set by A()