Atmosphere/atmosphere — Issue #205: Cannot instantiate 2 JGroupsFilters w/ default constructor
Author: jwestra
Created: 2012-03-02 19:08:42+00:00
State: open

The constructor for JGroupsFilter is this:

public JGroupsFilter() {

this(BroadcasterFactory.getDefault().get(DefaultBroadcaster.class,
"JGroupFilter"));
}

So, if the code ever calls this constructor more than once you will
get that exception.

In my app, I do the following when a page for Accounts subscribes to
the "accounts" topic:
1. look up a Broadcaster (ex: "accounts")
2. if there is a broadcast filter configured for it, the code
instantiates it (e.g., my ClusterBroadcastFilter is a JGroupsFilter)
3. adds the broadcast filter to the "accounts" Broadcaster

Then, for a page that deals with Customers, I use the "customers"
broadcaster name to do same thing:
1. look up a Broadcaster (ex: "customers")
2. if there is a broadcast filter, it instantiates it (e.g.,
ClusterBroadcastFilter is a JGroupFilter)

BOOM!

[org.atmosphere.plugin.jgroups.JGroupsFilter]: Constructor threw
exception; nested exception is java.lang.IllegalStateException:
Broadcaster already existing JGroupFilter. Use
BroadcasterFactory.lookup instead