2rr
Sep 1st, 2009, 04:34 PM
Hi,
In my application I use Flex, BlazeDS, Spring, Spring Security and Spring BlazeDS integration.
My problem is that I am not sure how to handle timeouts correctly. I was hoping that I could set up a listener on the server which triggers on session timeout and then sends a notification to the client. I tried to implement this by creating a custom Adapter which extends ServiceAdapter and implements FlexSessionListener.
public void sessionCreated(FlexSession session) {
session.addSessionDestroyedListener(this);
}
public void sessionDestroyed(FlexSession session) {
//MessageService msgService = (MessageService) getDestination().getService();
MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
...
}
@Override
public Object invoke(Message message) {...}
I hoped that this class would trigger the sessionCreated method when logging in, and the sessionDestroyed method when loggin out (and timeout).
And so it does when I register it as a listener in Web.xml .The problem then is that MessageBroker.getMessageBroker(null) returns null. (And the invoke method never runs).
I should probably define this in the application-context like this:
<flex:remoting-destination ref="testPush" channels="my-streaming-amf" service-adapter="TestAdapter"/>
and this to the messaging-service.xml file:
<adapters>
<adapter-definition id="TestAdapter" class="package.TestListener"/>
</adapters>
But now I get this error message: No adapter with id 'TestAdapter' is registered with the service 'remoting-service'.
Can someone please tell me why? What am I doing wrong?
And a second question:
Is the following correct: To be able to push the timeout notification (in sessionDestroyed) to the client I have to set up a new Channel like this:
<channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
And then use Producer and Consumer on the client side to handle the timeout notification.(So far I have only used RemoteObjects)
I'm new to blazeDS so I would be delighted to get some opinions on how to best handle session timeouts.
In my application I use Flex, BlazeDS, Spring, Spring Security and Spring BlazeDS integration.
My problem is that I am not sure how to handle timeouts correctly. I was hoping that I could set up a listener on the server which triggers on session timeout and then sends a notification to the client. I tried to implement this by creating a custom Adapter which extends ServiceAdapter and implements FlexSessionListener.
public void sessionCreated(FlexSession session) {
session.addSessionDestroyedListener(this);
}
public void sessionDestroyed(FlexSession session) {
//MessageService msgService = (MessageService) getDestination().getService();
MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
...
}
@Override
public Object invoke(Message message) {...}
I hoped that this class would trigger the sessionCreated method when logging in, and the sessionDestroyed method when loggin out (and timeout).
And so it does when I register it as a listener in Web.xml .The problem then is that MessageBroker.getMessageBroker(null) returns null. (And the invoke method never runs).
I should probably define this in the application-context like this:
<flex:remoting-destination ref="testPush" channels="my-streaming-amf" service-adapter="TestAdapter"/>
and this to the messaging-service.xml file:
<adapters>
<adapter-definition id="TestAdapter" class="package.TestListener"/>
</adapters>
But now I get this error message: No adapter with id 'TestAdapter' is registered with the service 'remoting-service'.
Can someone please tell me why? What am I doing wrong?
And a second question:
Is the following correct: To be able to push the timeout notification (in sessionDestroyed) to the client I have to set up a new Channel like this:
<channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
And then use Producer and Consumer on the client side to handle the timeout notification.(So far I have only used RemoteObjects)
I'm new to blazeDS so I would be delighted to get some opinions on how to best handle session timeouts.