Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.advisories
Class ProducerDemandAdvisor  view ProducerDemandAdvisor download ProducerDemandAdvisor.java

java.lang.Object
  extended byorg.activemq.advisories.ProducerDemandAdvisor

public class ProducerDemandAdvisor
extends java.lang.Object

A ProducerDemandAdvisor is used to know when a destination is in demand. Sometimes generating messages to send to a destination is very expensive and the application would like to avoid producing messages if there are no active consumers for the destination. There is a "demand" for messages when a consumer does come active. This object uses Advisory messages to know when consumer go active and inactive.


Field Summary
private  javax.jms.Connection connection
           
private  int consumerCount
           
private  ProducerDemandListener demandListener
           
private  org.activemq.message.ActiveMQDestination destination
           
private static org.apache.commons.logging.Log log
           
private  javax.jms.Session session
           
private  SynchronizedBoolean started
           
 
Constructor Summary
ProducerDemandAdvisor(javax.jms.Connection connection, javax.jms.Destination destination)
           
 
Method Summary
private  void fireDemandEvent()
           
 ProducerDemandListener getDemandListener()
           
 boolean isInDemand()
           
protected  void process(javax.jms.Message msg)
           
 void setDemandListener(ProducerDemandListener demandListener)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

destination

private final org.activemq.message.ActiveMQDestination destination

connection

private javax.jms.Connection connection

session

private javax.jms.Session session

started

private SynchronizedBoolean started

consumerCount

private int consumerCount

demandListener

private ProducerDemandListener demandListener
Constructor Detail

ProducerDemandAdvisor

public ProducerDemandAdvisor(javax.jms.Connection connection,
                             javax.jms.Destination destination)
                      throws javax.jms.JMSException
Method Detail

fireDemandEvent

private void fireDemandEvent()

isInDemand

public boolean isInDemand()

getDemandListener

public ProducerDemandListener getDemandListener()

setDemandListener

public void setDemandListener(ProducerDemandListener demandListener)

start

public void start()
           throws javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException

process

protected void process(javax.jms.Message msg)