We're not revealing any secrets when I explain you what we're doing.
Franck, I'll send the relevant code in an email.
Our Flex client application can subscribe for application events to e.g., display them in a monitor.
The client subscribes with a filter known by id, which is conveyed to the server as selector text.
The server has a singleton service that dispatches events to subscribed clients (dispatcher).
This service has a ref to a (the?) Gravity instance, which it gets injected from a servlet
attribute listener at system startup. See a former discussion on that at
https://groups.google.com/forum/#!searchin/graniteds/maarel/graniteds/ow4vDgVKzRQ/0ETRSsb67CoJThe dispatcher service receives an event to be dispatched, so it uses the Gravity instance to send
an event message to interested clients.
It uses a selector of ours that is based on the Gravity subscription id (i.e., the
AsyncMessage.DESTINATION_CLIENT_ID_HEADER property) to decide where the event
message should go.
As always, the selector is constructed by at subscription time in the gravity Subscription object.
In the ServiceAdapter of our own (that extends your SimpleServiceAdapter) we take the selector text
from the subscribe command message to tell another service of ours what event filter must be used
and we set the selector text in the subscription command to contain the subscription id like this
String sid = (String)msg.getHeader(AsyncMessage.DESTINATION_CLIENT_ID_HEADER);
msg.setHeader(CommandMessage.SELECTOR_HEADER, "SubscriptionId = '" + sid + "'");
where msg is the subscribe command. This selector text is later on used by our selector to match
the subscribers.
This scheme has worked with GDS 2.2.1. It also works with GDS 2.3.1. The difference between the two is
in the connects that stay away and therefore subsequent resubscribe that we see.
I have played a little more with the gravity config. We use Tomcat+APR with JBoss-4.2.3. It appears that
there is no CONNECT command coming in. Quite possibly because it isn't sent. Which is likely to happen because
the long polling request isn't ended. I've tested with the default settings: after half an hour no CONNECT
requests have come in, so Gravity submits an unsubscribe command, upon which the client resubscribes, as can
also be seen in the log in the previous post in this thread.
Thanks,
Eric