1 Reply Latest reply on Mar 19, 2012 9:11 AM by t3rm1

    How to set max consumer rate for a queue at runtime?

    abc2011 Newbie

      I have to set at runtime the max consumer rate for a queue using a specific connection factory. I want to get througput value from jmx console and in my mbean I do:

       

      @Override

                public void setThroughput(int throughput) {

                          this.throughput = throughput;

                          try {

                                    HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();

                                    qResourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());

                                    qResourceAdapter.setConnectionParameters("server-id=0");

                                    qResourceAdapter.setHA(true);

                                    qResourceAdapter.start(ctx);

                                    HornetQActivationSpec spec = new HornetQActivationSpec();

                                    spec.setResourceAdapter(qResourceAdapter);

                                    spec.setUseJNDI(false);

                                    spec.setDestinationType("javax.jms.Queue");

                                    spec.setDestination("queue/MyQueue");

       

                                    HornetQConnectionFactory fac = qResourceAdapter

                                                        .createHornetQConnectionFactory(spec);

                                    spec.setConsumerMaxRate(throughput);

                                    qResourceAdapter.stop();

                                    qResourceAdapter.start(ctx);

       

                          } catch (Exception e) {

                                    logger.error("error: ", e);

                          }

       

      but the rate doesn't change after this operation.

      Can you help me?

       

      Messaggio modificato da abc2011 I'm using JBoss 5.1.0-GA and hornetq 2.2.5.Final. In JNDI tree is possible publish the resource adapter reference?