1 Reply Latest reply on Aug 22, 2012 9:09 PM by Joel Pearson

    AS 7.1.1 HornetQ Reaper Thread not Reaping

    Joel Pearson Newbie



      I originally posted this on the JBoss AS 7 forum https://community.jboss.org/thread/204241?tstart=30 but since it's more related to HornetQ, I thought I'd post it here as well.


      I'm using AS 7.1.1 with stock HornetQ (2.2.13.Final), and I'm having problems expiring messages.


      I'm using standalone-full.xml and this is the JMS section of the file, with my "queue/ControlQueue" JMS queue:

              <subsystem xmlns="urn:jboss:domain:messaging:1.1">
                          <netty-connector name="netty" socket-binding="messaging"/>
                          <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                              <param key="batch-delay" value="50"/>
                          <in-vm-connector name="in-vm" server-id="0"/>
                          <netty-acceptor name="netty" socket-binding="messaging"/>
                          <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                              <param key="batch-delay" value="50"/>
                              <param key="direct-deliver" value="false"/>
                          <in-vm-acceptor name="in-vm" server-id="0"/>
                          <address-setting match="#">
                          <connection-factory name="InVmConnectionFactory">
                                  <connector-ref connector-name="in-vm"/>
                                  <entry name="java:/ConnectionFactory"/>
                          <connection-factory name="RemoteConnectionFactory">
                                  <connector-ref connector-name="netty"/>
                                  <entry name="RemoteConnectionFactory"/>
                                  <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                          <pooled-connection-factory name="hornetq-ra">
                              <transaction mode="xa"/>
                                  <connector-ref connector-name="in-vm"/>
                                  <entry name="java:/JmsXA"/>
                          <jms-queue name="ControlQueue">
                              <entry name="queue/ControlQueue"/>


      The relevant pool snippet:


      <strict-max-pool name="control-mdb-strict-max-pool" max-pool-size="1" instance-acquisition-timeout="2" instance-acquisition-timeout-unit="MINUTES"/>


      My JMS sender looks like this:


         @Resource(mappedName = "java:/ConnectionFactory")
         private ConnectionFactory connectionFactory;
         @Resource(mappedName = "java:/queue/ControlQueue")
         private Queue controlQueue;
         @Schedule(second = "*/1", minute = "*", hour = "*", persistent = false)
         public void testControlQueue() {
            try {
               Connection connection = this.connectionFactory.createConnection();
               try {
                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  MessageProducer sender = session.createProducer(this.controlQueue);
                  TextMessage message = session.createTextMessage("Hi! " + new Date());
               finally {
                  // Clean up any resources.
                  if (connection != null) {
            catch (JMSException jmse) {
               // TODO Auto-generated catch block
               Loggers.business.error("JMS send failed", jmse);


      And my MDB looks like this:


      @Pool(value = "control-mdb-strict-max-pool")
      @MessageDriven(activationConfig = {
            @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/queue/ControlQueue") })
      public class ControlMessageDrivenBean implements MessageListener {
         public void onMessage(Message message) {
            if (message instanceof TextMessage) {
               TextMessage textMessage = (TextMessage) message;
               try {
                  Loggers.business.info("Received message: [" + textMessage.getText() + "]");
               catch (JMSException jmse) {
                  // Log an error rather than throw an exception. There is no point trying to re-process this message (which
                  // will happen if an exception is thrown).
                  Loggers.business.error("Could not retrieve text from message [" + textMessage + "]", jmse);
               catch (InterruptedException e) {
                  // TODO Auto-generated catch block


      I downloaded the hornetQ source and put a break point on the queue and when the reaper runs it seems to think my queue is empty. But I can see from the logging output, that it is definately queuing up my messages, because it processes each message one by one, and the date increases by 1 second, instead of expiring the messages that were queued up while the MDB was sleeping.


      Inside "org.hornetq.core.server.impl.QueueImpl.expireReferences()" the iterator always appears to be empty.  Is there some limitation where queue using an "in-vm" queue doesn't support expiration?