Event Queues"

From Documentation
(Created page with '{{ZKComponentReferencePageHeader}} = Overview = An event queue is an event-based publish-subscribe solution for application information delivery and messaging. It provides async…')
 
Line 13: Line 13:
  
 
= Identification of an Event 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 <tt>lookup</tt> method of <javadoc>org.zkoss.zk.ui.event.EventQueues</javadoc>. For example,
 +
 +
<source lang="java">
 +
EventQueues.lookup("myQueue"); //assumes the desktop scope
 +
EventQueues.lookup("anotherQueue", EventQueues.SESSION);
 +
EventQueues.lookup("anotherQueue", session);
 +
</source>
 +
 +
Notice that if you want to locate an event queue in a working thread (rather than an event listener), you have to use <javadoc method="lookup(java.lang.String, org.zkoss.zk.ui.Session)">org.zkoss.zk.ui.event.EventQueues</javadoc> or <javadoc method="lookup(java.lang.String, org.zkoss.zk.ui.Application)">org.zkoss.zk.ui.event.EventQueues</javadoc>, depending on your requirement.
  
 
== The Scope of an Event Queue ==
 
== The Scope of an Event Queue ==
  
 
{{ZKComponentReferencePageFooter}}
 
{{ZKComponentReferencePageFooter}}

Revision as of 04:14, 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. Eventqueue-concept.jpg

The purpose of event queues are two folds:

  1. Simplify the many-to-many communication.
  2. 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


Last Update : 2010/08/25

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.