NickGreen February 2016

Updating Apache Ignite WebSession attributes

We are currently integrating Apache Ignite in our application to share sessions in a cluster. See Ignite docs. At this point we can successfully share sessions between two local tomcat instances, but there's one use case, which (seems) is not supported by Ignite.

In our application, we have an session object which is called 'Profile'. This profile is user specific and all kinds of attributes are added to this object while the user browses through the application.

We update the 'Profile' object in the following way (pseudo code):

profile = request.getSession().getProfile(); //Get Profile object from session
profile.setLastVisitedPage("test");

Without Apache Ignite, our session will contain the correct value for 'setLastVisitedPage' ('test'). But when using Ignite, the Ignite 'WebSession' object seems to work a bit different: when setting the 'setLastVisitedPage' value in the session object, the WebSession will first correctly contain the correct value ('test'), but when browsing to the next page, the WebSession object, which is resolved from the Ignite cache doesn't contain the changed 'setLastVisitedPage' attribute.

I've taken a look at the Ignite code and I think, I know why this is not working as expected. Looking at the Ignite 'WebSession' class, I see the following method:

public void setAttribute(String name, Object val) {
    attrs.put(name, val);

    if (updates != null)
        updates.add(new T2<>(name, val));
}

In short: Ignite expects that after every update to a session object, you call the session.setAttribute method, so Ignite will add the change to it's internal 'updates' collection, which is used to update the object in the Ignite grid. A solution for our application would be to change our applications code, to call setAttribute after every update, but we also us

Answers


Valentin February 2016

You're right, that's how it is implemented right now and the only workaround is to explicitly call setAttribute() on each update. I think this can be improved and created an Apache Ignite ticket: https://issues.apache.org/jira/browse/IGNITE-2594

Post Status

Asked in February 2016
Viewed 3,325 times
Voted 9
Answered 1 times

Search




Leave an answer