Event Queues"
Line 40: | Line 40: | ||
| The event queue is visible only in the same desktop. | | The event queue is visible only in the same desktop. | ||
|- | |- | ||
− | | group | + | | group |
+ | |||
| <javadoc method="lookup(java.lang.String, java.lang.String)">org.zkoss.zk.ui.event.EventQueues</javadoc><br/> | | <javadoc method="lookup(java.lang.String, java.lang.String)">org.zkoss.zk.ui.event.EventQueues</javadoc><br/> | ||
<javadoc method="lookup(java.lang.String, java.lang.String, boolean)">org.zkoss.zk.ui.event.EventQueues</javadoc> | <javadoc method="lookup(java.lang.String, java.lang.String, boolean)">org.zkoss.zk.ui.event.EventQueues</javadoc> | ||
− | | The event queue is visible only in a group of desktops that belongs to the same browser. It is formed if iframe or frameset is used. Some portal container might cause a group of desktops to be formed too. | + | | |
+ | [since 5.0.4][ZK EE] | ||
+ | The event queue is visible only in a group of desktops that belongs to the same browser. It is formed if iframe or frameset is used. Some portal container might cause a group of desktops to be formed too. | ||
Unlike the session and application scope, the group scope doesn't require the server push, so the communication is more efficient. | Unlike the session and application scope, the group scope doesn't require the server push, so the communication is more efficient. | ||
|- | |- |
Revision as of 04:58, 25 August 2010
Overview
An event queue is an event-based publish-subscribe solution for application information delivery and messaging. It provides asynchronous communications for different modules/roles in a loosely-coupled and autonomous fashion.
By publishing, a module (publisher) sends out messages without explicitly specifying or having knowledge of intended recipients. By subscribing, a receiving module (subscriber) receives messages that the subscriber has registered an interest in, without explicitly specifying or knowing the publisher.
The purpose of event queues are two folds:
- Simplify the many-to-many communication.
- Make the application independent of the underlining communication mechanism. The application remains the same, while the event queue can be implemented by use of Ajax, server push and even message queue.
Identification of an Event Queue
An event queue is identified by a name and a scope. The scope represents the visibility of an event queue. For example, a desktop-scoped event queue is visible in the same desktop, while application-scoped event queue is visible in the whole application.
Locate an Event Queue
You could locate an event queue by invoking one of the lookup method of EventQueues. For example,
EventQueues.lookup("myQueue"); //assumes the desktop scope
EventQueues.lookup("anotherQueue", EventQueues.SESSION);
EventQueues.lookup("anotherQueue", session);
Notice that if you want to locate an event queue in a working thread (rather than an event listener), you have to use EventQueues.lookup(String, Session) or EventQueues.lookup(String, Application), depending on your requirement.
The Scope of an Event Queue
There are currently four different scopes: desktop, group, session and application. In additions, you add your own scope, such as message queue to communicate among several servers.
Name | API | Description |
---|---|---|
desktop | EventQueues.lookup(String, String) |
The event queue is visible only in the same desktop. |
group | EventQueues.lookup(String, String) |
[since 5.0.4][ZK EE] The event queue is visible only in a group of desktops that belongs to the same browser. It is formed if iframe or frameset is used. Some portal container might cause a group of desktops to be formed too. Unlike the session and application scope, the group scope doesn't require the server push, so the communication is more efficient. |
session | EventQueues.lookup(String, String) EventQueues.lookup(String, String, boolean) |
The event queue is visible only in the same session. The server push will be enabled automatically. |
application | EventQueues.lookup(String, String) EventQueues.lookup(String, String, boolean) |
The event queue is visible only in the whole application. The server push will be enabled automatically. |
Add a Custom Scope
Version History
Version | Date | Content |
---|---|---|
5.0.4 | August 2010 | The group scope was introduced to allow the communication among inline frames without Server Push (minimizing the network bandwidth consumption). |