Controlling Queues with RedwoodScript 
When you have a lot of repetitive tasks to perform, it is often easier to use script. RedwoodScript allows you to control queues, and you can hold all queues, regardless of the total number, with a few lines of code. The following examples illustrate how you can use RedwoodScript to control queues. Redwood Software does not warrant that this is the most effective way to solve your problem. For more information on RedwoodScript, see the API documentation.
{
// get the queue
aQ = jcsSession.getQueueByName("TR2_Queue");
// check to see if the queue is open
if (aQ.isOpen())
{
//hold the queue
aQ.hold();
jcsSession.persist();
}
}
This is an example of how you can retrieve the status of a queue.
{
//get the queue
Queue aQ = jcsSession.getQueueByName("TR2_Queue");
//check if the queue is open
if (aQ.isOpen())
{
//queue is open
aQ.hold();
jcsSession.persist();
}
else
{
//queue is held
aQ.release();
jcsSession.persist();
}
}
You can hold all queues, except system queue.
{
for (Iterator it = jcsSession.executeObjectQuery("select Queue.* from Queue where Name <> 'System'",null); it.hasNext();)
{
Queue queue = (Queue) it.next();
if(queue.isOpen())
{
jcsOut.println("Holding queue "+ queue.getName()+", which has the status "+ queue.getStatus()+".");
queue.hold();
jcsSession.persist();
}
}
}
{
Queue queue = jcsSession.getQueueByName("TR1_Queue");
ProcessServer proc = jcsSession.getProcessServerByName("TR2_ProcessServer");
queue.createQueueProvider(proc);
jcsSession.persist();
}
A queue provider is the link between a process server and a queue, to find all the process servers serving a queue, we need to list the queue providers.
{
for (Iterator it = queue.getQueueProviders(); it.hasNext();)
{
QueueProvider provider = (QueueProvider) it.next();
out.println(provider.getProcessServer().getName());
}
}