|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openeai.OpenEaiObject
org.openeai.jms.producer.ProducerPool
public class ProducerPool
The ProducerPool is a class that contains a list of producers for use by an application or command. It is very similar to a Database Connection pool in that it is filled with pre-configured and started producers when the application starts up. This is to allow developers to affect the performance of an application by adding producers to a pool relative to the amount of processing and number of threads present in the application. Since OpenEAI producers are by default thread safe, it does not do anything to limit the number of threads accessing a producer at the same time. It simply makes the number of producers producing to the same queue higher so their will be a smaller number of synchronizations occurring within the producers (when a message is produced and Session synchronization occurrs).
ProducerConfig| Field Summary |
|---|
| Fields inherited from class org.openeai.OpenEaiObject |
|---|
logger |
| Constructor Summary | |
|---|---|
ProducerPool()
Constructor |
|
ProducerPool(java.util.List vProducers)
|
|
| Method Summary | |
|---|---|
MessageProducer |
getExclusiveProducer()
Returns an EXCLUSIVE producer from the pool. |
MessageProducer |
getProducer()
Returns the next producer from the pool. |
java.util.List |
getProducers()
Returns the list of OpenEAI producers associated to this pool. |
void |
releaseProducer(MessageProducer producer)
Release a previously retrieved Exclusive producer to the pool. |
void |
setProducers(java.util.List vProducers)
Sets the list of OpenEAI producers to what's passed in. |
int |
size()
Returns the size of the pool. |
| Methods inherited from class org.openeai.OpenEaiObject |
|---|
getAppName, getDebug, getFromAddr, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setAppName, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProducerPool()
public ProducerPool(java.util.List vProducers)
| Method Detail |
|---|
public final void setProducers(java.util.List vProducers)
vProducers - java.util.Listpublic final java.util.List getProducers()
public final int size()
public final MessageProducer getProducer()
throws javax.jms.JMSException
If a producer is not started, it will not be returned.
javax.jms.JMSException - if no started producers can be found in the pool.
public final MessageProducer getExclusiveProducer()
throws javax.jms.JMSException
By obtaining an exclusive producer, you're ensuring that the thread requesting the producer from the pool is the only thread that should be using that producer at that time and therefore anything committed on that producer will be related to the messages published by that thread only.
Generally, this method SHOULD NOT be called if the pool contains PointToPointProducers because there is no need to obtain an exclusive producer in that case.
When the getExclusiveProducer method is called, a flag is set so that any subsequent retrievals from the pool will not return the same producer until the producer has been released back to the pool via the releaseProducer(MessageProducer) method.
This method DOES NOT attempt to create a new producer if there are none available in the pool. Instead, it "blocks" until one becomes available. Because of this, it is critical that if using this method, you promptly release the producer back to the pool when you're done with it. Otherwise, all producers will become unavailable and it will be impossible to retrieve any producers from this particular pool resulting in an endless loop.
NOTE: Applications using the getExclusiveProducer method on a ProducerPool should NOT use the getProducerMethod on that same pool. This will confuse things and may result in un-expected behavior since the getProducer method doesn't care about multiple threads accessing the same producer.
javax.jms.JMSException - if no started producers can be found in the pool.releaseProducer(MessageProducer),
getProducer()public final void releaseProducer(MessageProducer producer)
producer - the MessageProducer to release back to the pool.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||