org.mule.streaming
Class QueueProducer<T>

java.lang.Object
  extended by org.mule.streaming.QueueProducer<T>
All Implemented Interfaces:
Closeable, Producer<T>, ProvidesTotalHint

public class QueueProducer<T>
extends Object
implements Producer<T>

Implementation of Producer to stream the contents of a Queue A polling timeout value might be specified, otherwise the default value of 5000 milliseconds will be assumed


Constructor Summary
QueueProducer(Queue queue)
          Creates an instance with 5000 milliseconds as the default polling value
QueueProducer(Queue queue, long timeout)
           
 
Method Summary
 void close()
          Closes the resource.
 T produce()
          Returns the next available item
 int size()
          returns the total amount of items available for storage/processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueProducer

public QueueProducer(Queue queue)
Creates an instance with 5000 milliseconds as the default polling value

Parameters:
queue - the queue to stream from

QueueProducer

public QueueProducer(Queue queue,
                     long timeout)
Method Detail

produce

public T produce()
Returns the next available item This implementation will poll from the queue once and will return the obtained item. If the producer is closed or if the queue times out while polling, then null is returned. If the poll method throws InterruptedException then null is returned as well

Specified by:
produce in interface Producer<T>
Returns:
an item. Might be null

close

public void close()
           throws MuleException
Description copied from interface: Closeable
Closes the resource. Calling this method is mandatory for any component using this instance once it finishes using it. This method should not throw exception is invoked on an instance that has already been closed

Specified by:
close in interface Closeable
Throws:
MuleException - if an exception occurs closing the resource

size

public int size()
Description copied from interface: ProvidesTotalHint
returns the total amount of items available for storage/processing. In some scenarios, it might not be possible/convenient to actually retrieve this value or it might not be available at this point. -1 is returned in such a case.

Specified by:
size in interface ProvidesTotalHint


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.