Fabric3 makes implementing highly-available clustered singletons trivial by using the @Scope("DOMAIN") annotation:
Code Block | ||||
---|---|---|---|---|
| ||||
@Scope("DOMAIN")
public class TheComponent ... {
public void onEvent(Event event) {
//...
}
}
|
As explained in Lifecycle and Scopes Java Components, a clustered singleton instance is created on the zone leader. If the leader fails or otherwise becomes inactive, a new instance is created on the newly elected leader.
...
- Timers that can only have a single emitter but must be highly-available (see Timer Components)
- Consumers that listen on a remote channel bound to a transport such as JMS which can only have one instance active at a time