I have two queues on my application (Spring3-Hibernate-ActiveMq). Thanks for your comments in advance. I would be glad if you help me avoid the following error:
10:02:41,541 INFO KahaStore:463 – Kaha Store using data directory \tmp\kahadb
10:02:41,542 INFO KahaPersistenceAdapter:185 – Store is locked… waiting 10 seconds for the Store to be unlocked.
10:02:51,542 INFO KahaStore:463 – Kaha Store using data directory \tmp\kahadb
10:02:51,543 INFO KahaPersistenceAdapter:185 – Store is locked… waiting 10 seconds for the Store to be unlocked.
10:03:01,543 INFO KahaStore:463 – Kaha Store using data directory \tmp\kahadb
..
.
And Here is my applicationContext.xml
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="vm://localhost" />
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="amqConnectionFactory" />
<property name="sessionCacheSize" value="100" />
</bean>
<bean id="jmsTemplateForProduct" class="org.springframework.jms.core.JmsTemplate"
p:defaultDestinationName="Click.Queue.Product">
<constructor-arg ref="connectionFactory" />
</bean>
<bean id="jmsTemplateForPayment" class="org.springframework.jms.core.JmsTemplate"
p:defaultDestinationName="Click.Queue.Payment">
<constructor-arg ref="connectionFactory" />
</bean>
<jms:listener-container concurrency="10">
<jms:listener id="ProductListener" destination="Click.Queue.Product"
ref="productListener" />
</jms:listener-container>
<jms:listener-container concurrency="10">
<jms:listener id="PaymentListener" destination="Click.Queue.Payment"
ref="paymentListener" />
</jms:listener-container>
<!-- ActiveMQ ends -->
Well, I have solved the problem by myself. BTW thanks jkysam for your comments.
The problem was occured because of loading of applicationContext more than once. So, anytime applicationContext is loaded, a new instance of kaha db is created and it results to locking.
What I did is that I seperated jms related configuration from applicationContext. So, I created a new context xml file called jmsContext.xml, and move the jms (and activemq as well) related configuration lines to that file. Then in my test classes, I loaded different context xml’s depend on whether it is a jmsTest or not.
For instance; I have two GenericUnitTest class in order to seperate context configuration. First is:
Second one is:
And then I extend these classes depend on the test case. Here is the example;
The non-jms test class sample is:
BTW, I exclude component scan filters which are about queue in applicationContext.xml, And include them in jmsContext.xml. Here is the example;
applicationContext xml is below
jmsContext xml is below