Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveMq: Exceeded the maximum number of allowed client connections

In my .Net application all components are interacting with ActiveMQ but after processing few messages, it starts giving error:

"Could not accept connection : org.apache.activemq.transport.tcp.ExceededMaximumConnectionsException: Exceeded the maximum number of allowed client connections.".

I have increased maximum number of connection in web config but its not working. I heard that for this scenario you should use PooledConnectionFactory. Can you guys please suggest how we can implement PooledConnectionFactory or is there any other alternative of it.

Thanks in Advance !!

like image 961
semwal Avatar asked Sep 04 '17 10:09

semwal


People also ask

What does connection limit has been exceeded mean?

This means you've had enough concurrent connections to surpass your limit or hit a warning.

Could not accept connection exceeded the maximum number of allowed client connections?

If you try to connect to your email using multiple computers with multiple email clients, you can exceed the maximum number of permitted connections. However, this is only a temporary restriction. To resolve the error, all you need to do is reduce the number of concurrent connections by closing your mail applications.

What is ActiveMQ transport connector?

The VM transport allows clients to connect to each other inside the VM without the overhead of the network communication. The connection used is not that of a socket connection but instead uses direct method invocations to enable a high performance embedded messaging system.


2 Answers

First of all you can configure how many connections the broker will accept in the brokers transport connector configuration, e.g. in your activemq.xml

<transportConnectors>
  <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000"/>
</transportConnectors>

1000 connections should be the default limit configured in the Apache distribution of ActiveMQ. Unless you have an unexpectedly low limit you are probably leaking connections in your client application, which should be easy to verify using commands like netstat.

I am not the ActiveMQ NMS expert but to my knowledge there is no PooledConnectionFactory for .NET

http://activemq.apache.org/nms/msdoc/1.6.0/vs2005/Output/html/N_Apache_NMS.htm

This is only available for Java. The previous reply is right, you should try to re-use existing connections into the broker. Connection creation is considered a heavy operation. Re-creating connections each time is an anti-pattern and leaking connections would of course be a bug.

like image 161
Torsten Mielke Avatar answered Sep 22 '22 16:09

Torsten Mielke


Try reuse your Connection somehow when producing messages. Like, keep an open connection around rather than open/close for each message.

There is a CachingConnectionFactory provided in Spring.NET that may simplify this task.

like image 31
Petter Nordlander Avatar answered Sep 20 '22 16:09

Petter Nordlander