sunlabs.brazil.template
public class QueueTemplate extends Template
The following tags are recognized.
<enqueue name="recipients ..." data=var1 var2 ... varn"
[glob="..." delim="." from="sender" nocreate="true|false"] >
<dequeue name="name" prepend="props prefix"
timelimit="sec">
If "timelimit" has a suffix of "ms", then the time is taken in ms.
<queueinfo name="q_name" prepend="props prefix" clear
remove=true|false create=true|false>
<enqueue name="recipients ..." meta="anything" message="msg"
from="sender" [nocreate="true|false"] >
Version: @(#)QueueTemplate.java 1.5 1.5
Nested Class Summary | |
---|---|
static class | QueueTemplate.Queue
Create an object queue. |
static class | QueueTemplate.QueueItem
A bag of items to keep on the Q.
|
Field Summary | |
---|---|
static String | Q_ID |
Method Summary | |
---|---|
static QueueTemplate.QueueItem | dequeue(String name, int timelimit)
Program access to the Q. |
static void | destroyQueue(String name)
Remove a Queue, freeing its resources. |
static boolean | enqueue(String to, String from, String message, String meta, boolean noCreate, boolean force)
Allow a message to be enqueued from java code.
|
static boolean | enqueue(String to, String from, Dictionary data, boolean noCreate, boolean force)
Allow a message to be enqueued from java code. |
static QueueTemplate.Queue | getQ(String name, boolean create)
Return a Q.
|
static QueueTemplate.Queue | getQ(String name) |
void | tag_dequeue(RewriteContext hr)
Remove an item from the queue, and generate the appropriate properties.
|
void | tag_enqueue(RewriteContext hr)
Add a text message onto a named queue.
|
void | tag_queueinfo(RewriteContext hr)
Return info about the Q, and optionally clear or remove it.
|
Parameters: name; The name of the Q. A new Q will be created if it doesn't already exist. timelimit: how long (in ms) to wait before returning
Returns: The Queue item, or Null if no item is available.
Deprecated:
Allow a message to be enqueued from java code. Use the {@link #enqueue(String to, String from, Dictionary data, boolean noCreate, boolean force)} method instead.Parameters: to: The queue name from: The sender of the data message: The message to enqueue meta: The meta data, if any noCreate: If true, don't create a Q if it doesn't already exist force: Force item onto Q even if it is closed
Returns: True, if the data was enqueued
Parameters: to: The queue name (only a single q) from: The sender of the data data: a dictionary f name/value pairs noCreate: If true, don't create a Q if it doesn'a already exist force: Force item onto Q even if it is closed
Returns: True, if the data was enqueued
Note: this tag blocks until an item is received in the Queue (or a timelimit expires). As template processing is synchronized based on sessions, care should be taken to avoid blocking other (unrelated) session based requests while waiting on the queue.
delim
list of queues to send the data too.The property "count" contains the number of recipients for which the message was successfully Queued. The property "error.name" will contain an error message if Queueing failed. In both cases, the template prefix will be prepended. It is not considered an error condition for a message not to be delivered to a non existent Queue if "nocreate" is set.
The experimental attribute "glob" may be used instead of "name", in which case name is taken as the list of "delim" separated tokens named by the first wildcard substring of the matching glob pattern.