Q: when messages(30,000+) flood in, the consumer server established too many TCP , even more than 10,000 .how to configer in spring to avoid that?!
Asked
Active
Viewed 1,481 times
-1
-
1Welcome to So, avoid putting screenshot of code instead of pasting them directly into the question. – Mohamed ALOUANE Jun 01 '17 at 13:14
1 Answers
0
This stackoverflow question might help: How is concurrency in Spring AMQP Listener Container implemented?
Quick excerpt, see 'concurrency':
<rabbit:listener-container connection-factory="myConnectionFactory" acknowledge="none" concurrency="10" requeue-rejected="false"> <rabbit:listener ref="myListener" queues="myQueue"/> </rabbit:listener-container>
I am not using the Spring XML configuration, but annotations, but this is what I have used to limit the amount of concurrent consumers:
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
// process each message one at a time
factory.setConcurrentConsumers(1);
factory.setMaxConcurrentConsumers(1);
return factory;
}

Erik Pearson
- 1,363
- 1
- 11
- 20
-
as I know , listeners use long connection, i send message using short connection to MQ after consuming . Is that right? If so , it is sending message caused too many TCPs , why need i change the listeners config ? – counterFish Jun 06 '17 at 03:39
-
@counterFish You have my attempt at an answer above. Give that a try. If it works, great, if not, feel free to comment and say it didn't work for you. – Erik Pearson Jun 07 '17 at 17:36