I'm trying to use cached connections but can't seem to figure out what I'm doing wrong.
Here's an excerpt from my configuration:
And here's the exception I get when I use SendAndConvert() from NmsTemplateCode:<object id="mqConnFactoryNoCache" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ"> <constructor-arg index="0" value="tcp://localhost:61616"/> </object> <object id="mqConnFactory" type="Spring.Messaging.Nms.Connections.CachingConnectionFactory, Spring.Messaging.Nms"> <constructor-arg name="targetConnectionFactory" ref="mqConnFactoryNoCache"/> <property name="SessionCacheSize" value="10"/> </object> <object id="nmsTemplate" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms"> <constructor-arg name="connectionFactory" ref="mqConnFactory"/> <property name="DefaultDestinationName" value="application.default"/> <property name="Persistent" value="true"/> <property name="ReceiveTimeout" value="3000"/> <property name="SessionAcknowledgeMode" value="ClientAcknowledge"/> </object>
The application has multiple producers, consumers, and queues. Is there anything obviously wrong with the above?Code:Apache.NMS.ActiveMQ.ConnectionClosedException: The connection is already closed! at Apache.NMS.ActiveMQ.MessageProducer.CheckClosed() in c:\project\3rdparty\asf\activemq-dotnet\Apache.NMS.ActiveMQ\trunk\src\main\csharp\MessageProducer.cs:line 114 at Apache.NMS.ActiveMQ.MessageProducer.Send(IDestination destination, IMessage message, Boolean persistent, Byte priority, TimeSpan timeToLive, Boolean specifiedTimeToLive) in c:\project\3rdparty\asf\activemq-dotnet\Apache.NMS.ActiveMQ\trunk\src\main\csharp\MessageProducer.cs:line 141 at Apache.NMS.ActiveMQ.MessageProducer.Send(IDestination destination, IMessage message) in c:\project\3rdparty\asf\activemq-dotnet\Apache.NMS.ActiveMQ\trunk\src\main\csharp\MessageProducer.cs:line 126 at Apache.NMS.ActiveMQ.MessageProducer.Send(IMessage message) in c:\project\3rdparty\asf\activemq-dotnet\Apache.NMS.ActiveMQ\trunk\src\main\csharp\MessageProducer.cs:line 121 at Spring.Messaging.Nms.Connections.CachedMessageProducer.Send(IMessage message) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Connections\CachedMessageProducer.cs:line 77 at Spring.Messaging.Nms.Core.NmsTemplate.DoSend(IMessageProducer producer, IMessage message) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 575 at Spring.Messaging.Nms.Core.NmsTemplate.DoSend(ISession session, IDestination destination, IMessageCreator messageCreator, MessageCreatorDelegate messageCreatorDelegate) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 545 at Spring.Messaging.Nms.Core.NmsTemplate.DoSend(ISession session, IDestination destination, IMessageCreator messageCreator) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 511 at Spring.Messaging.Nms.Core.SendDestinationCallback.DoInNms(ISession session) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 1479 at Spring.Messaging.Nms.Core.NmsTemplate.Execute(ISessionCallback action, Boolean startConnection) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 187 at Spring.Messaging.Nms.Core.NmsTemplate.Send(String destinationName, IMessageCreator messageCreator) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 736 at Spring.Messaging.Nms.Core.NmsTemplate.ConvertAndSend(String destinationName, Object message) in c:\project\3rdparty\spring.net\src\Spring\Spring.Messaging.Nms\Messaging\Nms\Core\NmsTemplate.cs:line 783


Reply With Quote
i don't know of what the practical limits in activemq are for the number of session/consumers/producers per connection but it should be quite high and it doesn't sound like you are using that many. If you are doing very long processing tasks before doing the client ack, I can see how that might cause some issues in as much as that is probably not that good practice to wait very long. The possible retry of an long running data-load (due to error) should be separated from the fact that the message was delivered successfully to the process.