今天下午发现公司的activemq消息系统异常,在某个topics上堆积了大量消息,后来发现是有开发同学直接在生产环境上测试,以durable subscription方式订阅消息,应为是测试, 消费不及时, 导致大量消息堆积。
   停止activemq后重新启动, 发现服务总是起不来, 查看日志文件有如下异常

  1. 2011-09-16 16:39:03,220 | INFO  | Using Persistence Adapter: KahaDBPersistenceAdapter[/mnt/gfs2/mq-as-2/kahadb1] | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain 
  2. 2011-09-16 16:39:03,824 | INFO  | KahaDB is version 2 | org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain 
  3. 2011-09-16 16:39:03,841 | INFO  | Recovering from the journal ... | org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain 
  4. 2011-09-16 16:39:03,841 | INFO  | Recovery replayed 1 operations from the journal in 0.012 seconds. | org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain 
  5. 2011-09-16 16:39:03,849 | INFO  | ActiveMQ 5.4.1 JMS Message Broker (mq-asc) is starting | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain 
  6. 2011-09-16 16:39:03,849 | INFO  | For help or more information please see: http://activemq.apache.org/ | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain 
  7. 2011-09-16 16:39:03,986 | INFO  | Scheduler using directory: activemq-data/mq-asc/scheduler | org.apache.activemq.broker.scheduler.SchedulerBroker | WrapperSimpleAppMain 
  8. 2011-09-16 16:39:04,066 | ERROR | Failed to start ActiveMQ JMS Message Broker. Reason: java.io.EOFException: Chunk stream does not exist at page: 0 | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain 
  9. java.io.EOFException: Chunk stream does not exist at page: 0 
  10.         at org.apache.kahadb.page.Transaction$2.readPage(Transaction.java:454) 
  11.         at org.apache.kahadb.page.Transaction$2.<init>(Transaction.java:431) 
  12.         at org.apache.kahadb.page.Transaction.openInputStream(Transaction.java:428) 
  13.         at org.apache.kahadb.page.Transaction.load(Transaction.java:404) 
  14.         at org.apache.kahadb.page.Transaction.load(Transaction.java:361) 
  15.         at org.apache.activemq.broker.scheduler.JobSchedulerStore$3.execute(JobSchedulerStore.java:250) 
  16.         at org.apache.kahadb.page.Transaction.execute(Transaction.java:728) 
  17.         at org.apache.activemq.broker.scheduler.JobSchedulerStore.doStart(JobSchedulerStore.java:239) 
  18.         at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:53) 
  19.         at org.apache.activemq.broker.scheduler.SchedulerBroker.getStore(SchedulerBroker.java:198) 
  20.         at org.apache.activemq.broker.scheduler.SchedulerBroker.getInternalScheduler(SchedulerBroker.java:185) 
  21.         at org.apache.activemq.broker.scheduler.SchedulerBroker.start(SchedulerBroker.java:85) 
  22.         at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:157) 
  23.         at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:157) 
  24.         at org.apache.activemq.broker.TransactionBroker.start(TransactionBroker.java:112) 
  25.         at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:157) 
  26.         at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:157) 
  27.         at org.apache.activemq.broker.BrokerService$3.start(BrokerService.java:1786) 
  28.         at org.apache.activemq.broker.BrokerService.start(BrokerService.java:496) 
  29.         at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60) 
  30.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  31.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  32.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  33.         at java.lang.reflect.Method.invoke(Method.java:597) 
  34.         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1536) 
  35.         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) 
  36.         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409) 
  37.         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
  38.         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
  39.         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) 
  40.         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
  41.         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) 
  42.         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) 
  43.         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574) 
  44.         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) 
  45.         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 

网上找了一把, 发现是由于 5.4.1 这个版本引入了 延迟发送的功能引起的, 解决方式也很简单,在<broker>中添加 schedulerSupport="false" 属性,禁掉scheduler功能就可以了。