I would like someone to point me to the right direction for some requirements: We need to have asynchronous reliable notification sent across our server The consumers of the messages will subscribe/unsubscribe at will The consumers will be large at number The producer will be one The notifications, even if server goes down, will not be lost and if server goes up again will be sent. The number of notifications is expected to be high The number of threads used should be as low as possible.
Given the above (crazy) requirements, i tried to solve this problem using activemq/jms. Does this seem like the proper direction?
Given the above: 1. i used durable subscribers and jms messages and kahadb. 2 For jms producer, the solution seems straight forward. 3. For the consumer side, i am in trouble.
a. Although i have spring, i could not use jms:listener-container since i need to have dynamic subscription and unsubscription of consumers and this seemed imposible so i create for every listener that i have, a SimpleListenerContainer. This sounds ok? b. In SimpleListenerContainer, i set clientId (since this is what is needed for durable)
super.setSubscriptionDurable(durable);
if (durable ) super.setClientId(clientId);
Here, i have the following. Given the following configuration:
<bean id="messageBusReceiverConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="maxConnections" value="10"/>
<property name="maximumActive" value="500"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="idleTimeout" value="0"/>
</bean>
I expected to have 10*500=5000 parallel consumers possible. This is true if consumers are not durable. But, for durable consumers, where super.setClientId(clientId) (super is SimpleMessageListenerContainer) is used, after 10th connection, i get: org.springframework.jms.IllegalStateException: Setting clientID on a used Connection is not allowed; nested exception is javax.jms.IllegalStateException: Setting clientID on a used Connection is not allowed
So it seems i cannot use durable subscribers using SimpleMessageListenerContainer for sessions, only for the connections. Is this true? Does it sound reasonable to have maxConnections=500 and maximumActive=1? This solves my problem, but... although new to JMS, this seems like overkill for the broker.
Ok, considering i am still in the right track, i need to unsubscribe now my consumer/listenr, dynamically so i do
container.stop();
container.destroy();
where container is SimpleMessageListenerContainer. container.destroy(); throws some exceptions when called. Is it necessary to call it or stop method is enough?
Ok, i know these questions are arbitary and perhaps difficult to answer even for someone who knows jms (if jms is the right solution) and have given next to nothing from my code. I expect someone to give me some guidance on wheather i am in the right track, give me from input as much as he can on the questions raised, and then i can give code in the places needed so as to solve my remaining problems.