Add reconnection logic to SimpleMessageListenerContainer.

Test for SimpleMessageListenerContainer's ExceptionListener being invoked (SPRNET-542)
This commit is contained in:
markpollack
2008-08-12 02:55:54 +00:00
parent 2e55bc71b4
commit 21fe0a1919
6 changed files with 12 additions and 13 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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)
{

View File

@@ -149,7 +149,7 @@ namespace Spring.Messaging.Nms.Connections
IConnection connection = new TestConnection();
Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
mocks.ReplayAll();

View File

@@ -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>