Add reconnection logic to SimpleMessageListenerContainer.
Test for SimpleMessageListenerContainer's ExceptionListener being invoked (SPRNET-542)
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// SessionCacheSize property in case of a high-concurrency environment.
|
||||
/// </remarks>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class CachingConnectionFactory : SingleConnectionFactory
|
||||
{
|
||||
#region Logging Definition
|
||||
|
||||
@@ -275,15 +275,14 @@ namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
con.ClientId = ClientId;
|
||||
}
|
||||
if (ExceptionListener != null || ReconnectOnException)
|
||||
if (reconnectOnException)
|
||||
{
|
||||
IExceptionListener listenerToUse = ExceptionListener;
|
||||
if (ReconnectOnException)
|
||||
{
|
||||
//add reconnect exception handler first.
|
||||
con.ExceptionListener += new ExceptionListener(this.OnException);
|
||||
}
|
||||
con.ExceptionListener += new ExceptionListener(listenerToUse.OnException);
|
||||
//add reconnect exception handler first to exception chain.
|
||||
con.ExceptionListener += new ExceptionListener(this.OnException);
|
||||
}
|
||||
if (ExceptionListener != null)
|
||||
{
|
||||
con.ExceptionListener += new ExceptionListener(ExceptionListener.OnException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -898,7 +898,7 @@ namespace Spring.Messaging.Nms.Core
|
||||
{
|
||||
CheckMessageConverter();
|
||||
Send(destinationName, new ConvertAndSendMessageCreator(this, message, postProcessor));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Receive a message synchronously from the default destination, but only
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
public void OnException(Exception exception)
|
||||
{
|
||||
// First invoke the user-specific ExceptionListener, if any.
|
||||
//InvokeExceptionListener(exception);
|
||||
InvokeExceptionListener(exception);
|
||||
// now try to recover the shared Connection and all consumers...
|
||||
if (logger.IsInfoEnabled)
|
||||
{
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
IConnection connection = new TestConnection();
|
||||
|
||||
Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
|
||||
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<object id="SimpleMessageListener" type="Spring.Messaging.Nms.Integration.SimpleMessageListener, Spring.Messaging.Nms.Tests"/>
|
||||
|
||||
|
||||
<object name="NmsTemplate" type="Spring.Messaging.Nms.NmsTemplate, Spring.Messaging.Nms">
|
||||
<object name="NmsTemplate" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
|
||||
<property name="ConnectionFactory" ref="ConnectionFactory"/>
|
||||
<property name="DefaultDestinationName" value="test.queue"/>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user