I am testing recovery of ActiveMQ by having a client continuously putting messages to a queue and then stopping the broker (Ctrl-C) and restarting it. During startup I get the following stack trace on ActiveMQ trunk version:
ERROR: java.lang.Exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.act
ivemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exceptio
n is java.io.IOException: Recovery Failed: The subscription does not exist: ID:FE-Z2965-2798-1210158536046-1:0:-1:2
java.lang.Exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.x
bean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is ja
va.io.IOException: Recovery Failed: The subscription does not exist: ID:FE-Z2965-2798-1210158536046-1:0:-1:2
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:99)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:129)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
at org.apache.activemq.console.Main.main(Main.java:106)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBean
BrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.io.IOEx
ception: Recovery Failed: The subscription does not exist: ID:FE-Z2965-2798-1210158536046-1:0:-1:2
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBean
Factory.java:1260)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFa
ctory.java:438)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.j
ava:383)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFact
ory.java:353)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:1
69)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactor
y.java:400)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationConte
xt.java:736)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:96)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:52)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
at org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:111)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:73)
... 10 more
Caused by: java.io.IOException: Recovery Failed: The subscription does not exist: ID:FE-Z2965-2798-1210158536046-1:0:-1:2
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
at org.apache.activemq.broker.TransactionBroker.start(TransactionBroker.java:110)
at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:153)
at org.apache.activemq.broker.BrokerFilter.start(BrokerFilter.java:153)
at org.apache.activemq.broker.MutableBrokerFilter.start(MutableBrokerFilter.java:160)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:444)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:50)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableB
eanFactory.java:1288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBean
Factory.java:1257)
... 29 more
Caused by: java.lang.IllegalArgumentException: The subscription does not exist: ID:FE-Z2965-2798-1210158536046-1:0:-1:2
at org.apache.activemq.broker.region.AbstractRegion.acknowledge(AbstractRegion.java:357)
at org.apache.activemq.broker.region.RegionBroker.acknowledge(RegionBroker.java:470)
at org.apache.activemq.broker.TransactionBroker.acknowledge(TransactionBroker.java:194)
at org.apache.activemq.broker.TransactionBroker$1.recover(TransactionBroker.java:100)
at org.apache.activemq.store.amq.AMQTransactionStore.recover(AMQTransactionStore.java:196)
at org.apache.activemq.broker.TransactionBroker.start(TransactionBroker.java:92)
... 36 more
I am wondering whether the AbstractRegion.acknowledge() method shouldn't consider the ConsumerBrokerExchange.getConnectionContext().getInRecoveryMode() flag and then NOT throw an IllegalArgumentException if no matching Subscription is available (while recovering during startup of the TransactionBroker there won't be any Subscriptions available anyway, right?) ...
Any thoughts?
Kai