Here's the situation I'm trying to resolve:
Code: Select all
public class Handler1 extends BaseClientRequestHandler {
@Override
public void handleClientRequest(User user, ISFSObject params) {
synchronized (user) {
user.setProperty("Handler1Called", true);
}
}
}
public class Handler2 extends BaseClientRequestHandler {
@Override
public void handleClientRequest(User user, ISFSObject params) {
synchronized (user) {
if(user.getProperty("Handler1Called") != null) {
// do stuff
}
}
}
}
My client sends the requests in the correct order (Handler1 then Handler2), they transfer over tcp so the server receives them in the correct order, however the requests go into separate thread pools and the handlers aren't guaranteed to be called in the correct order.
Currently the options I can come up with to resolve this are:
- Reduce my extension thread pool size to 1
- Create a response callback for Handler1 and have the client wait on a round trip before sending Handler2
Neither of which are ideal.
What I'd like to see is an option to have all requests from the same user routed to the same thread queue (could remove the sync blocks as well) or some other method to ensures the handlers are called in the same order the commands are received.
Thanks