activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: How to limit a queue capacity
Date Thu, 01 Feb 2007 13:06:25 GMT
You could also write an Interceptor to block (or reject) inbound
messages from being sent if the queue is too big.

http://incubator.apache.org/activemq/interceptors.html


On 1/31/07, itayke <exalinkcom@yahoo.com> wrote:
>
> There is something I don't understand:
> In here
> http://incubator.apache.org/activemq/what-happens-with-a-fast-producer-and-slow-consumer.html
> http://incubator.apache.org/activemq/what-happens-with-a-fast-producer-and-slow-consumer.html
> they are saing that a slow consumer will cause the producer to slow down
> also, but if there is no "built-in" limitation on the queue size/capacity,
> then how can it be done? What will stop the queue from growing to (almost)
> infinity?
>
>
>
>
> Eichberger, German wrote:
> >
> > We solved this by asking the queue every time before we inserted
> > something how many message are there, e.g. in your producer do the
> > following:
> >
> > public static synchronized void initJMX(long port) {
> >       try {
> >               JMXServiceURL url = new
> > JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"+port+"/jmxrmi")
> > ;
> >                       JMXConnector conn =
> > JMXConnectorFactory.connect(url);
> >                       mbs = conn.getMBeanServerConnection();
> >       } catch (Exception e) {
> >               log.error("Exception obtaining #messages in queue:" +
> > e.getMessage());
> >       }
> >
> >
> >     }
> >
> >     public long getQueueSize(ActiveMQQueue destination) throws
> > Exception{
> >       try {
> >               String name = "org.apache.activemq" +
> > ":Type=Queue,Destination=" +
> >               destination.getQueueName() + ",BrokerName=localhost";
> >
> >       ObjectName queueViewMBeanName = new ObjectName(name);
> >
> >       if (mbs.isRegistered(queueViewMBeanName)) {
> >
> >               QueueViewMBean queue = (QueueViewMBean)
> > MBeanServerInvocationHandler.newProxyInstance(mbs, queueViewMBeanName,
> > QueueViewMBean.class, true);
> >
> >
> >               long size = queue.getQueueSize();
> >               log.info("Queue: " + queueViewMBeanName + " now has: " +
> > size + " message(s)");
> >               return size;
> >       } else {
> >               log.error("Bean not registered");
> >               throw new Exception("Bean not registered");
> >       }
> >       } catch (Exception e) {
> >               log.error("Exception obtaining #messages in queue:" +
> > e.getMessage());
> >               throw new Exception(e);
> >       }
> >     }
> >
> > Then you call the function in the produicer and decide if you can send
> > the message...
> >
> > You also need to enable JMX on your JVM.
> >
> > German
> >
> >
> >
> > -----Original Message-----
> > From: itayke [mailto:exalinkcom@yahoo.com]
> > Sent: Tuesday, January 30, 2007 4:49 AM
> > To: activemq-users@geronimo.apache.org
> > Subject: How to limit a queue capacity
> >
> >
> > Hi,
> >
> > I like to limit the capacity of a queue (lets say to maximum of 5
> > messages).
> >
> > 1. How is it done?
> > 2. what shall happen to a producer that will try to send the 6th message
> > to
> > this queue?
> >
> > Thanks
> > --
> > View this message in context:
> > http://www.nabble.com/How-to-limit-a-queue-capacity-tf3142214.html#a8708
> > 859
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-limit-a-queue-capacity-tf3142214.html#a8724272
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message