Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messages lost with SessionBroadcasterCache on broadcast #743

Closed
survivant opened this issue Nov 26, 2012 · 1 comment
Closed

messages lost with SessionBroadcasterCache on broadcast #743

survivant opened this issue Nov 26, 2012 · 1 comment

Comments

@survivant
Copy link
Member

There is a problem with SessionBroadcasterCache, if the user use this Cache within his Interceptor.

Suppose that I'm in a AtmosphereHandler.

...
out.sendMessage(Message1);
...
out.sendMessage(Message2);
...

out.broadcast("new [user1] connected");
..

in my Interceptor, I override the out.sendMessage(String); to cache the message and send it later. Like if I'm doing aggregation.

Instead of using my own Cache, I'm using the cache declared in web.xml, atmosphere.xml or by annotation :

``java
@AtmosphereHandlerService(
path = "/*",
supportSession=true,
broadcasterCache=SessionBroadcasterCache.class)

the problem is here :

the Broadcaster will call : trackMessage(...)
and will arrive here :

SessionBroadcasterCache.addToCache(String broadcasterId, AtmosphereResource r, Message message) {

...
session.setAttribute(broadcasterId, String.valueOf(now));
...

at the last line.. it will reset the index to the last item inserted. So it will be "new [user1] connected".

when in my Interceptor when I call

public List retrieveFromCache(String broadcasterId, AtmosphereResource r) {

....

I received the last item, not the 2 others.

Could we have a way to retreive the messages not sent (by removing them from the cache when retrieveFromCache() is called). If the sent failed, the Interceptor could readded them in the cache manually.

What do you think ?

@xenster86
Copy link

I suppose this issue is duplicate of #658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants