1
votes

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.

1
complex question? too broad to be answered through one post? silly question? I am not very used from stack overflow to have ananswered question for so much time. I have done done it like I mention above with JMS, so i guess this question is not urgent or something from my side anymore. But if someone wishes some support on how i did it, please let me know and i can share some info. I am not sure though if i followed the best approach.Alexandros
is this resolved ?Akshay Naik

1 Answers

1
votes

I am lacking the knowledge about spring to answer your question about the IllegalStateException, though I would guess it is related to maxConnections being set to 10.

Do you need spring? In any case, make sure that you have persistence enabled in your JMS Broker's configuration, make sure to use a durable queue/topic and make sure to use setDurable(true) on the message.

I think you generally made the right decision to use a powerful JMS provider if you want reliable messaging. You can test various products with the SPECjms2007 benchmark, depending on how important performance is for you, there are also some results available.