I hate GUIs
Now that I got that off my chest, I have a problem with an
applet receiving a JMS issue. The problem stems from the fact that we will be running the application in both a web browser as well as Web Start.
As it stands, when init() is called, the applet registers itself as a listener to a JMS destination. When destroy() is called, the applet unsubscribes.
In Web Start, there is a panel that holds the applet. This gets initialized when the application starts up, since even though the panel isn't visible, it's still there. The user also has the option of opening up a separate window for each panel, which causes a new applet to be initialized. This caused multiple listeners for the one JMS destination to exist, therefore one client was receiving the same message multiple times. A simple static boolean and an if block took care of this.
However, the browser is a different story. The applet doesn't get initialized unless the person clicks on a link. This works the first time, but if they leave and go back to the link, destroy() is called causing the applet to unsubscribe. And when you click on the link to go back to the applet, it isn't subscribing again because the static boolean was set to think it already subscribed. So messages are received once, then not again.
So I had destroy() set the static boolean to false, so it would reinitialize. This caused the duplicate messages to appear again in Web Start (since destroy() was being called when the "second" applet was created).
And finally, in the browser, you still want the user to receive messages even if they aren't in that applet. So there has to be some check at destroy time to find out if they are still waiting to receive a message, and only unsubscribe when that message is received.
And of course the requirements don't want to force the user to stay in the applet until they receive a message, or to only have one version of the applet up in Web Start, such as the panel.
I'm trying to play with a way to design the least amount of counters or checkers to ensure that both versions of the application send only one message to the client, even if the client isn't in the applet, or has multiple versions of the applet up.
JMS messages are filtered by session ID.
So, if you actually comprehended all that, I'd be glad to hear any suggestions.
Thanks!
[ August 18, 2003: Message edited by: jason adam ]