rename messaging classes to remove used of NMS prefix.
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </summary>
|
||||
/// <remarks>Checks <see cref="ISmartConnectionFactory.ShouldStop"/>, if available.
|
||||
/// This is essentially a more sophisticated version of
|
||||
/// <see cref="NmsUtils.CloseConnection(IConnection, bool)"/>
|
||||
/// <see cref="MessagingUtils.CloseConnection(IConnection, bool)"/>
|
||||
/// </remarks>
|
||||
/// <param name="connection">The connection to release. (if this is <code>null</code>, the call will be ignored)</param>
|
||||
/// <param name="cf">The ConnectionFactory that the Connection was obtained from. (may be <code>null</code>)</param>
|
||||
@@ -93,7 +93,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
return false;
|
||||
}
|
||||
NmsResourceHolder resourceHolder = (NmsResourceHolder) TransactionSynchronizationManager.GetResource(cf);
|
||||
MessageResourceHolder resourceHolder = (MessageResourceHolder) TransactionSynchronizationManager.GetResource(cf);
|
||||
return (resourceHolder != null && resourceHolder.ContainsSession(session));
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ namespace Spring.Messaging.Nms.Connections
|
||||
AssertUtils.ArgumentNotNull(resourceKey, "Resource key must not be null");
|
||||
AssertUtils.ArgumentNotNull(resourceKey, "ResourceFactory must not be null");
|
||||
|
||||
NmsResourceHolder resourceHolder =
|
||||
(NmsResourceHolder)TransactionSynchronizationManager.GetResource(resourceKey);
|
||||
MessageResourceHolder resourceHolder =
|
||||
(MessageResourceHolder)TransactionSynchronizationManager.GetResource(resourceKey);
|
||||
if (resourceHolder != null)
|
||||
{
|
||||
ISession rhSession = resourceFactory.GetSession(resourceHolder);
|
||||
@@ -162,10 +162,10 @@ namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
return null;
|
||||
}
|
||||
NmsResourceHolder resourceHolderToUse = resourceHolder;
|
||||
MessageResourceHolder resourceHolderToUse = resourceHolder;
|
||||
if (resourceHolderToUse == null)
|
||||
{
|
||||
resourceHolderToUse = new NmsResourceHolder();
|
||||
resourceHolderToUse = new MessageResourceHolder();
|
||||
}
|
||||
|
||||
IConnection con = resourceFactory.GetConnection(resourceHolderToUse);
|
||||
@@ -214,7 +214,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
if (resourceHolderToUse != resourceHolder)
|
||||
{
|
||||
TransactionSynchronizationManager.RegisterSynchronization(
|
||||
new NmsResourceSynchronization(resourceKey, resourceHolderToUse,
|
||||
new MessageResourceSynchronization(resourceKey, resourceHolderToUse,
|
||||
resourceFactory.SynchedLocalTransactionAllowed));
|
||||
resourceHolderToUse.SynchronizedWithTransaction = true;
|
||||
TransactionSynchronizationManager.BindResource(resourceKey, resourceHolderToUse);
|
||||
@@ -243,12 +243,12 @@ namespace Spring.Messaging.Nms.Connections
|
||||
this.synchedLocalTransactionAllowed = synchedLocalTransactionAllowed;
|
||||
}
|
||||
|
||||
public virtual ISession GetSession(NmsResourceHolder holder)
|
||||
public virtual ISession GetSession(MessageResourceHolder holder)
|
||||
{
|
||||
return holder.GetSession(typeof(ISession), existingCon);
|
||||
}
|
||||
|
||||
public virtual IConnection GetConnection(NmsResourceHolder holder)
|
||||
public virtual IConnection GetConnection(MessageResourceHolder holder)
|
||||
{
|
||||
return (existingCon != null ? existingCon : holder.GetConnection());
|
||||
}
|
||||
@@ -285,29 +285,29 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </summary>
|
||||
public interface ResourceFactory
|
||||
{
|
||||
/// <summary> Fetch an appropriate Session from the given NmsResourceHolder.</summary>
|
||||
/// <param name="holder">the NmsResourceHolder
|
||||
/// <summary> Fetch an appropriate Session from the given MessageResourceHolder.</summary>
|
||||
/// <param name="holder">the MessageResourceHolder
|
||||
/// </param>
|
||||
/// <returns> an appropriate Session fetched from the holder,
|
||||
/// or <code>null</code> if none found
|
||||
/// </returns>
|
||||
ISession GetSession(NmsResourceHolder holder);
|
||||
ISession GetSession(MessageResourceHolder holder);
|
||||
|
||||
/// <summary> Fetch an appropriate Connection from the given NmsResourceHolder.</summary>
|
||||
/// <param name="holder">the NmsResourceHolder
|
||||
/// <summary> Fetch an appropriate Connection from the given MessageResourceHolder.</summary>
|
||||
/// <param name="holder">the MessageResourceHolder
|
||||
/// </param>
|
||||
/// <returns> an appropriate Connection fetched from the holder,
|
||||
/// or <code>null</code> if none found
|
||||
/// </returns>
|
||||
IConnection GetConnection(NmsResourceHolder holder);
|
||||
IConnection GetConnection(MessageResourceHolder holder);
|
||||
|
||||
/// <summary> Create a new NMS Connection for registration with a NmsResourceHolder.</summary>
|
||||
/// <summary> Create a new NMS Connection for registration with a MessageResourceHolder.</summary>
|
||||
/// <returns> the new NMS Connection
|
||||
/// </returns>
|
||||
/// <throws>NMSException if thrown by NMS API methods </throws>
|
||||
IConnection CreateConnection();
|
||||
|
||||
/// <summary> Create a new NMS ISession for registration with a NmsResourceHolder.</summary>
|
||||
/// <summary> Create a new NMS ISession for registration with a MessageResourceHolder.</summary>
|
||||
/// <param name="con">the NMS Connection to create a ISession for
|
||||
/// </param>
|
||||
/// <returns> the new NMS Session
|
||||
@@ -329,17 +329,17 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
/// <summary> Callback for resource cleanup at the end of a non-native NMS transaction
|
||||
/// </summary>
|
||||
private class NmsResourceSynchronization : TransactionSynchronizationAdapter
|
||||
private class MessageResourceSynchronization : TransactionSynchronizationAdapter
|
||||
{
|
||||
private object resourceKey;
|
||||
|
||||
private NmsResourceHolder resourceHolder;
|
||||
private MessageResourceHolder resourceHolder;
|
||||
|
||||
private bool transacted;
|
||||
|
||||
private bool holderActive = true;
|
||||
|
||||
public NmsResourceSynchronization(object resourceKey, NmsResourceHolder resourceHolder, bool transacted)
|
||||
public MessageResourceSynchronization(object resourceKey, MessageResourceHolder resourceHolder, bool transacted)
|
||||
{
|
||||
this.resourceKey = resourceKey;
|
||||
this.resourceHolder = resourceHolder;
|
||||
|
||||
@@ -29,7 +29,7 @@ using Apache.NMS;
|
||||
namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
/// <summary>Connection holder, wrapping a NMS Connection and a NMS Session.
|
||||
/// NmsTransactionManager binds instances of this class to the thread,
|
||||
/// MessageTransactionManager binds instances of this class to the thread,
|
||||
/// for a given NMS ConnectionFactory.
|
||||
///
|
||||
/// <p>Note: This is an SPI class, not intended to be used by applications.</p>
|
||||
@@ -37,11 +37,11 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </summary>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class NmsResourceHolder : ResourceHolderSupport
|
||||
public class MessageResourceHolder : ResourceHolderSupport
|
||||
{
|
||||
#region Logging
|
||||
|
||||
private static readonly ILog logger = LogManager.GetLogger(typeof(NmsResourceHolder));
|
||||
private static readonly ILog logger = LogManager.GetLogger(typeof(MessageResourceHolder));
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -62,41 +62,41 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
#region Constructor (s)
|
||||
|
||||
/// <summary> Create a new NmsResourceHolder that is open for resources to be added.</summary>
|
||||
public NmsResourceHolder()
|
||||
/// <summary> Create a new MessageResourceHolder that is open for resources to be added.</summary>
|
||||
public MessageResourceHolder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmsResourceHolder"/> class
|
||||
/// Initializes a new instance of the <see cref="MessageResourceHolder"/> class
|
||||
/// at is open for resources to be added.
|
||||
/// </summary>
|
||||
/// <param name="connectionFactory">The connection factory that this
|
||||
/// resource holder is associated with (may be <code>null</code>)
|
||||
/// </param>
|
||||
public NmsResourceHolder(IConnectionFactory connectionFactory)
|
||||
public MessageResourceHolder(IConnectionFactory connectionFactory)
|
||||
{
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmsResourceHolder"/> class for the
|
||||
/// Initializes a new instance of the <see cref="MessageResourceHolder"/> class for the
|
||||
/// given Session.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
public NmsResourceHolder(ISession session)
|
||||
public MessageResourceHolder(ISession session)
|
||||
{
|
||||
AddSession(session);
|
||||
frozen = true;
|
||||
}
|
||||
|
||||
/// <summary> Create a new NmsResourceHolder for the given NMS resources.</summary>
|
||||
/// <summary> Create a new MessageResourceHolder for the given NMS resources.</summary>
|
||||
/// <param name="connection">the NMS Connection
|
||||
/// </param>
|
||||
/// <param name="session">the NMS Session
|
||||
/// </param>
|
||||
public NmsResourceHolder(IConnection connection, ISession session)
|
||||
public MessageResourceHolder(IConnection connection, ISession session)
|
||||
{
|
||||
AddConnection(connection);
|
||||
AddSession(session, connection);
|
||||
@@ -104,12 +104,12 @@ namespace Spring.Messaging.Nms.Connections
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmsResourceHolder"/> class.
|
||||
/// Initializes a new instance of the <see cref="MessageResourceHolder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="connectionFactory">The connection factory.</param>
|
||||
/// <param name="connection">The connection.</param>
|
||||
/// <param name="session">The session.</param>
|
||||
public NmsResourceHolder(IConnectionFactory connectionFactory, IConnection connection, ISession session)
|
||||
public MessageResourceHolder(IConnectionFactory connectionFactory, IConnection connection, ISession session)
|
||||
{
|
||||
this.connectionFactory = connectionFactory;
|
||||
AddConnection(connection);
|
||||
@@ -121,7 +121,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="NmsResourceHolder"/> is frozen, namely that
|
||||
/// Gets a value indicating whether this <see cref="MessageResourceHolder"/> is frozen, namely that
|
||||
/// additional resources can be registered with the holder. If using any of the constructors with
|
||||
/// a Session, the holder will be set to the frozen state.
|
||||
/// </summary>
|
||||
@@ -144,7 +144,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// <param name="connection">The connection.</param>
|
||||
public void AddConnection(IConnection connection)
|
||||
{
|
||||
AssertUtils.IsTrue(!frozen, "Cannot add IConnection because NmsResourceHolder is frozen");
|
||||
AssertUtils.IsTrue(!frozen, "Cannot add IConnection because MessageResourceHolder is frozen");
|
||||
AssertUtils.ArgumentNotNull(connection, "IConnection must not be null");
|
||||
if (!connections.Contains(connection))
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// <param name="connection">The connection.</param>
|
||||
public void AddSession(ISession session, IConnection connection)
|
||||
{
|
||||
AssertUtils.IsTrue(!frozen, "Cannot add ISession because NmsResourceHolder is frozen");
|
||||
AssertUtils.IsTrue(!frozen, "Cannot add ISession because MessageResourceHolder is frozen");
|
||||
AssertUtils.ArgumentNotNull(session, "ISession must not be null");
|
||||
if (!sessions.Contains(session))
|
||||
{
|
||||
@@ -23,6 +23,7 @@ using System;
|
||||
using System.Data;
|
||||
using Apache.NMS;
|
||||
using Common.Logging;
|
||||
using Spring.Messaging.Nms;
|
||||
using Spring.Objects.Factory;
|
||||
using Spring.Transaction;
|
||||
using Spring.Transaction.Support;
|
||||
@@ -39,7 +40,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// <para>
|
||||
/// Application code is required to retrieve the transactional Session via
|
||||
/// <see cref="ConnectionFactoryUtils.GetTransactionalSession"/>. Spring's
|
||||
/// <see cref="NmsTemplate"/> will autodetect a thread-bound Session and
|
||||
/// <see cref="MessageTemplate"/> will autodetect a thread-bound Session and
|
||||
/// automatically participate in it.
|
||||
/// </para>
|
||||
/// <para>
|
||||
@@ -57,24 +58,24 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </remarks>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class NmsTransactionManager : AbstractPlatformTransactionManager,
|
||||
public class MessageTransactionManager : AbstractPlatformTransactionManager,
|
||||
IResourceTransactionManager, IInitializingObject
|
||||
{
|
||||
|
||||
#region Logging Definition
|
||||
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(NmsTransactionManager));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(MessageTransactionManager));
|
||||
|
||||
#endregion
|
||||
|
||||
private IConnectionFactory connectionFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmsTransactionManager"/> class.
|
||||
/// Initializes a new instance of the <see cref="MessageTransactionManager"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The ConnectionFactory has to be set before using the instance.
|
||||
/// This constructor can be used to prepare a NmsTemplate via a ApplicationContext,
|
||||
/// This constructor can be used to prepare a MessageTemplate via a ApplicationContext,
|
||||
/// typically setting the ConnectionFactory via ConnectionFactory property.
|
||||
/// <para>
|
||||
/// Turns off transaction synchronization by default, as this manager might
|
||||
@@ -83,17 +84,17 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// Only one manager is allowed to drive synchronization at any point of time.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public NmsTransactionManager()
|
||||
public MessageTransactionManager()
|
||||
{
|
||||
TransactionSynchronization = TransactionSynchronizationState.Never;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmsTransactionManager"/> class
|
||||
/// Initializes a new instance of the <see cref="MessageTransactionManager"/> class
|
||||
/// given a ConnectionFactory.
|
||||
/// </summary>
|
||||
/// <param name="connectionFactory">The connection factory to obtain connections from.</param>
|
||||
public NmsTransactionManager(IConnectionFactory connectionFactory) : this()
|
||||
public MessageTransactionManager(IConnectionFactory connectionFactory) : this()
|
||||
{
|
||||
ConnectionFactory = connectionFactory;
|
||||
AfterPropertiesSet();
|
||||
@@ -145,15 +146,15 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the NmsTransactionObject.
|
||||
/// Get the MessageTransactionObject.
|
||||
/// </summary>
|
||||
/// <returns>he NmsTransactionObject.</returns>
|
||||
/// <returns>he MessageTransactionObject.</returns>
|
||||
protected override object DoGetTransaction()
|
||||
{
|
||||
NmsTransactionObject txObject = new NmsTransactionObject();
|
||||
MessageTransactionObject txObject = new MessageTransactionObject();
|
||||
|
||||
txObject.ResourceHolder =
|
||||
(NmsResourceHolder) TransactionSynchronizationManager.GetResource(ConnectionFactory);
|
||||
(MessageResourceHolder) TransactionSynchronizationManager.GetResource(ConnectionFactory);
|
||||
return txObject;
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
throw new InvalidIsolationLevelException("NMS does not support an isoliation level concept");
|
||||
}
|
||||
NmsTransactionObject txObject = (NmsTransactionObject) transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject) transaction;
|
||||
IConnection con = null;
|
||||
ISession session = null;
|
||||
try
|
||||
@@ -190,7 +191,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
log.Debug("Created NMS transaction on Session [" + session + "] from Connection [" + con + "]");
|
||||
}
|
||||
txObject.ResourceHolder = new NmsResourceHolder(ConnectionFactory, con, session);
|
||||
txObject.ResourceHolder = new MessageResourceHolder(ConnectionFactory, con, session);
|
||||
txObject.ResourceHolder.SynchronizedWithTransaction = true;
|
||||
int timeout = DetermineTimeout(definition);
|
||||
if (timeout != DefaultTransactionDefinition.TIMEOUT_DEFAULT)
|
||||
@@ -240,7 +241,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override object DoSuspend(object transaction)
|
||||
{
|
||||
NmsTransactionObject txObject = (NmsTransactionObject) transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject) transaction;
|
||||
txObject.ResourceHolder = null;
|
||||
return TransactionSynchronizationManager.UnbindResource(ConnectionFactory);
|
||||
}
|
||||
@@ -259,7 +260,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override void DoResume(object transaction, object suspendedResources)
|
||||
{
|
||||
NmsResourceHolder conHolder = (NmsResourceHolder) suspendedResources;
|
||||
MessageResourceHolder conHolder = (MessageResourceHolder) suspendedResources;
|
||||
TransactionSynchronizationManager.BindResource(ConnectionFactory, conHolder);
|
||||
}
|
||||
|
||||
@@ -272,7 +273,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override void DoCommit(DefaultTransactionStatus status)
|
||||
{
|
||||
NmsTransactionObject txObject = (NmsTransactionObject)status.Transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject)status.Transaction;
|
||||
ISession session = txObject.ResourceHolder.GetSession();
|
||||
try
|
||||
{
|
||||
@@ -299,7 +300,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override void DoRollback(DefaultTransactionStatus status)
|
||||
{
|
||||
NmsTransactionObject txObject = (NmsTransactionObject)status.Transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject)status.Transaction;
|
||||
ISession session = txObject.ResourceHolder.GetSession();
|
||||
try
|
||||
{
|
||||
@@ -326,7 +327,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override void DoSetRollbackOnly(DefaultTransactionStatus status)
|
||||
{
|
||||
NmsTransactionObject txObject = (NmsTransactionObject)status.Transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject)status.Transaction;
|
||||
txObject.ResourceHolder.RollbackOnly = true;
|
||||
}
|
||||
|
||||
@@ -345,7 +346,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </remarks>
|
||||
protected override void DoCleanupAfterCompletion(object transaction)
|
||||
{
|
||||
NmsTransactionObject txObject = (NmsTransactionObject)transaction;
|
||||
MessageTransactionObject txObject = (MessageTransactionObject)transaction;
|
||||
TransactionSynchronizationManager.UnbindResource(ConnectionFactory);
|
||||
txObject.ResourceHolder.CloseAll();
|
||||
txObject.ResourceHolder.Clear();
|
||||
@@ -365,7 +366,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// </exception>
|
||||
protected override bool IsExistingTransaction(object transaction)
|
||||
{
|
||||
NmsTransactionObject txObject = transaction as NmsTransactionObject;
|
||||
MessageTransactionObject txObject = transaction as MessageTransactionObject;
|
||||
if (txObject != null)
|
||||
{
|
||||
return txObject.ResourceHolder != null;
|
||||
@@ -396,15 +397,15 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// NMS Transaction object, representing a NmsResourceHolder.
|
||||
/// Used as transaction object by NmsTransactionManager
|
||||
/// NMS Transaction object, representing a MessageResourceHolder.
|
||||
/// Used as transaction object by MessageTransactionManager
|
||||
/// </summary>
|
||||
internal class NmsTransactionObject : ISmartTransactionObject
|
||||
internal class MessageTransactionObject : ISmartTransactionObject
|
||||
{
|
||||
private NmsResourceHolder resourceHolder;
|
||||
private MessageResourceHolder resourceHolder;
|
||||
|
||||
|
||||
public NmsResourceHolder ResourceHolder
|
||||
public MessageResourceHolder ResourceHolder
|
||||
{
|
||||
get { return resourceHolder; }
|
||||
set { resourceHolder = value; }
|
||||
@@ -38,7 +38,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
/// You can either pass in a specific Connection directly or let this
|
||||
/// factory lazily create a Connection via a given target ConnectionFactory.
|
||||
/// <para>Useful in order to keep using the same Connection for multiple
|
||||
/// <see cref="NmsTemplate"/> calls, without having a pooling ConnectionFactory
|
||||
/// <see cref="MessageTemplate"/> calls, without having a pooling ConnectionFactory
|
||||
/// underneath. This may span any number of transactions, even concurrently executing transactions.
|
||||
/// </para>
|
||||
/// <para>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Spring.Messaging.Nms
|
||||
/// <summary> Creates a NMS message given a Session</summary>
|
||||
/// <remarks>
|
||||
/// <p>The Session typically is provided by an instance
|
||||
/// of the NmsTemplate class.</p>
|
||||
/// of the MessageTemplate class.</p>
|
||||
/// </remarks>
|
||||
/// <author>Mark Pollack</author>
|
||||
public interface IMessageCreator
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Spring.Messaging.Nms
|
||||
/// <summary>Specifies a basic set of NMS operations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <p>Implemented by NmsTemplate. Not often used but a useful option
|
||||
/// <p>Implemented by MessageTemplate. Not often used but a useful option
|
||||
/// to enhance testability, as it can easily be mocked or stubbed.</p>
|
||||
///
|
||||
/// <p>Provides <code>NmsTemplate's</code> <code>send(..)</code> and
|
||||
/// <p>Provides <code>MessageTemplate's</code> <code>send(..)</code> and
|
||||
/// <code>receive(..)</code> methods that mirror various NMS API methods.
|
||||
/// See the NMS specification and NMS API docs for details on those methods.
|
||||
/// </p>
|
||||
@@ -36,7 +36,7 @@ namespace Spring.Messaging.Nms
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public interface INmsOperations
|
||||
public interface IMessageOperations
|
||||
{
|
||||
/// <summary> Execute the action specified by the given action object within
|
||||
/// a NMS Session.
|
||||
@@ -22,7 +22,7 @@ using Apache.NMS;
|
||||
|
||||
namespace Spring.Messaging.Nms
|
||||
{
|
||||
/// <summary> To be used with NmsTemplate's send method that
|
||||
/// <summary> To be used with MessageTemplate's send method that
|
||||
/// convert an object to a message.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Spring.Messaging.Nms
|
||||
{
|
||||
/// <summary> Callback for sending a message to a NMS destination.</summary>
|
||||
/// <remarks>
|
||||
/// <p>To be used with the NmsTemplate.Execute(IProducerCallback)
|
||||
/// <p>To be used with the MessageTemplate.Execute(IProducerCallback)
|
||||
/// method, often implemented as an anonymous inner class.</p>
|
||||
///
|
||||
/// <p>The typical implementation will perform multiple operations on the
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace Spring.Messaging.Nms
|
||||
/// Session
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <p>To be used with the NmsTemplate.Execute(ISessionCallback)}
|
||||
/// <p>To be used with the MessageTemplate.Execute(ISessionCallback)}
|
||||
/// method, often implemented as an anonymous inner class.</p>
|
||||
/// </remarks>
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <seealso cref="NmsTemplate.Execute(ISessionCallback,bool)">
|
||||
/// <seealso cref="MessageTemplate.Execute(ISessionCallback,bool)">
|
||||
/// </seealso>
|
||||
public interface ISessionCallback
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
/// Common base class for all containers which need to implement listening
|
||||
/// based on a Connection (either shared or freshly obtained for each attempt).
|
||||
/// Inherits basic Connection and Session configuration handling from the
|
||||
/// <see cref="NmsAccessor"/> base class.
|
||||
/// <see cref="MessagingAccessor"/> base class.
|
||||
/// </summary>
|
||||
/// <para>
|
||||
/// This class provides basic lifecycle management, in particular management
|
||||
@@ -45,11 +45,11 @@ namespace Spring.Messaging.Nms.Listener
|
||||
///
|
||||
/// </remarks>
|
||||
/// <author>Mark Pollack</author>
|
||||
public abstract class AbstractNmsListeningContainer : NmsDestinationAccessor, ILifecycle, IObjectNameAware, IDisposable
|
||||
public abstract class AbstractListenerContainer : MessageDestinationAccessor, ILifecycle, IObjectNameAware, IDisposable
|
||||
{
|
||||
#region Logging
|
||||
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(AbstractNmsListeningContainer));
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(AbstractListenerContainer));
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -439,7 +439,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
bool running = IsRunning;
|
||||
lock (this.sharedConnectionMonitor)
|
||||
{
|
||||
NmsUtils.CloseConnection(this.sharedConnection, running);
|
||||
MessagingUtils.CloseConnection(this.sharedConnection, running);
|
||||
|
||||
IConnection con = CreateConnection();
|
||||
try
|
||||
@@ -448,7 +448,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
NmsUtils.CloseConnection(con);
|
||||
MessagingUtils.CloseConnection(con);
|
||||
throw;
|
||||
}
|
||||
this.sharedConnection = con;
|
||||
@@ -473,7 +473,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
return con;
|
||||
} catch (NMSException)
|
||||
{
|
||||
NmsUtils.CloseConnection(con);
|
||||
MessagingUtils.CloseConnection(con);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
/// a standard NMS MessageListener or a Spring-specific
|
||||
/// <see cref="ISessionAwareMessageListener"/>
|
||||
/// </summary>
|
||||
public abstract class AbstractMessageListenerContainer : AbstractNmsListeningContainer
|
||||
public abstract class AbstractMessageListenerContainer : AbstractListenerContainer
|
||||
{
|
||||
#region Logging
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to expose listener session to a registered
|
||||
/// <see cref="ISessionAwareMessageListener"/> as well as to <see cref="NmsTemplate"/> calls.
|
||||
/// <see cref="ISessionAwareMessageListener"/> as well as to <see cref="MessageTemplate"/> calls.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default is "true", reusing the listener's Session.
|
||||
@@ -217,8 +217,8 @@ namespace Spring.Messaging.Nms.Listener
|
||||
/// underlying Connection instead, which might be necessary
|
||||
/// on some messaging providers.
|
||||
/// <para>Note that Sessions managed by an external transaction manager will
|
||||
/// always get exposed to <see cref="NmsTemplate"/>
|
||||
/// calls. So in terms of NmsTemplate exposure, this setting only affects
|
||||
/// always get exposed to <see cref="MessageTemplate"/>
|
||||
/// calls. So in terms of MessageTemplate exposure, this setting only affects
|
||||
/// locally transacted Sessions.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
@@ -412,13 +412,13 @@ namespace Spring.Messaging.Nms.Listener
|
||||
if (sessionToUse.Transacted && SessionTransacted)
|
||||
{
|
||||
// Transacted session created by this container -> commit.
|
||||
NmsUtils.CommitIfNecessary(sessionToUse);
|
||||
MessagingUtils.CommitIfNecessary(sessionToUse);
|
||||
}
|
||||
}
|
||||
} finally
|
||||
{
|
||||
NmsUtils.CloseSession(sessionToClose);
|
||||
NmsUtils.CloseConnection(conToClose);
|
||||
MessagingUtils.CloseSession(sessionToClose);
|
||||
MessagingUtils.CloseConnection(conToClose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
// Commit necessary - but avoid commit call is Session transaction is externally coordinated.
|
||||
if (IsSessionLocallyTransacted(session))
|
||||
{
|
||||
NmsUtils.CommitIfNecessary(session);
|
||||
MessagingUtils.CommitIfNecessary(session);
|
||||
}
|
||||
}
|
||||
else if (IsClientAcknowledge(session))
|
||||
@@ -472,7 +472,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
/// <returns>
|
||||
/// <c>true</c> if the is session locally transacted; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <see cref="NmsAccessor.SessionTransacted"/>
|
||||
/// <see cref="MessagingAccessor.SessionTransacted"/>
|
||||
protected virtual bool IsSessionLocallyTransacted(ISession session)
|
||||
{
|
||||
return SessionTransacted;
|
||||
@@ -489,7 +489,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
if (session.Transacted && IsSessionLocallyTransacted(session))
|
||||
{
|
||||
// Transacted session created by this container -> rollback
|
||||
NmsUtils.RollbackIfNecessary(session);
|
||||
MessagingUtils.RollbackIfNecessary(session);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -509,7 +509,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
{
|
||||
logger.Debug("Initiating transaction rollback on application exception");
|
||||
}
|
||||
NmsUtils.RollbackIfNecessary(session);
|
||||
MessagingUtils.RollbackIfNecessary(session);
|
||||
}
|
||||
} catch (NMSException)
|
||||
{
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace Spring.Messaging.Nms.Listener.Adapter
|
||||
}
|
||||
finally
|
||||
{
|
||||
NmsUtils.CloseMessageProducer(producer);
|
||||
MessagingUtils.CloseMessageProducer(producer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,18 +24,18 @@ using Spring.Messaging.Nms.Connections;
|
||||
namespace Spring.Messaging.Nms.Listener
|
||||
{
|
||||
/// <summary>
|
||||
/// NmsResourceHolder marker subclass that indicates local exposure,
|
||||
/// MessageResourceHolder marker subclass that indicates local exposure,
|
||||
/// i.e. that does not indicate an externally managed transaction.
|
||||
/// </summary>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class LocallyExposedNmsResourceHolder : NmsResourceHolder
|
||||
public class LocallyExposedMessageResourceHolder : MessageResourceHolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocallyExposedNmsResourceHolder"/> class.
|
||||
/// Initializes a new instance of the <see cref="LocallyExposedMessageResourceHolder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
public LocallyExposedNmsResourceHolder(ISession session) : base(session)
|
||||
public LocallyExposedMessageResourceHolder(ISession session) : base(session)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -236,12 +236,12 @@ namespace Spring.Messaging.Nms.Listener
|
||||
logger.Debug("Closing NMS MessageConsumers");
|
||||
foreach (IMessageConsumer messageConsumer in consumers)
|
||||
{
|
||||
NmsUtils.CloseMessageConsumer(messageConsumer);
|
||||
MessagingUtils.CloseMessageConsumer(messageConsumer);
|
||||
}
|
||||
logger.Debug("Closing NMS Sessions");
|
||||
foreach (ISession session in sessions)
|
||||
{
|
||||
NmsUtils.CloseSession(session);
|
||||
MessagingUtils.CloseSession(session);
|
||||
}
|
||||
consumers = null;
|
||||
sessions = null;
|
||||
@@ -295,7 +295,7 @@ namespace Spring.Messaging.Nms.Listener
|
||||
if (exposeResource)
|
||||
{
|
||||
TransactionSynchronizationManager.BindResource(
|
||||
container.ConnectionFactory, new LocallyExposedNmsResourceHolder(session));
|
||||
container.ConnectionFactory, new LocallyExposedMessageResourceHolder(session));
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
@@ -29,29 +29,29 @@ namespace Spring.Messaging.Nms
|
||||
/// Convenient super class for application classes that need NMS access.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Requires a ConnectionFactory or a NmsTemplate instance to be set.
|
||||
/// It will create its own NmsTemplate if a ConnectionFactory is passed in.
|
||||
/// A custom NmsTemplate instance can be created for a given ConnectionFactory
|
||||
/// Requires a ConnectionFactory or a MessageTemplate instance to be set.
|
||||
/// It will create its own MessageTemplate if a ConnectionFactory is passed in.
|
||||
/// A custom MessageTemplate instance can be created for a given ConnectionFactory
|
||||
/// through overriding the <code>createNmsTemplate</code> method.
|
||||
///
|
||||
/// </remarks>
|
||||
public class NmsGatewaySupport : IInitializingObject
|
||||
public class MessageGatewaySupport : IInitializingObject
|
||||
{
|
||||
|
||||
#region Logging
|
||||
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(NmsGatewaySupport));
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(MessageGatewaySupport));
|
||||
|
||||
#endregion
|
||||
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the NMS template for the gateway.
|
||||
/// </summary>
|
||||
/// <value>The NMS template.</value>
|
||||
public NmsTemplate NmsTemplate
|
||||
public MessageTemplate MessageTemplate
|
||||
{
|
||||
get { return jmsTemplate; }
|
||||
set { jmsTemplate = value; }
|
||||
@@ -59,7 +59,7 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets he NMS connection factory to be used by the gateway.
|
||||
/// Will automatically create a NmsTemplate for the given ConnectionFactory.
|
||||
/// Will automatically create a MessageTemplate for the given ConnectionFactory.
|
||||
/// </summary>
|
||||
/// <value>The connection factory.</value>
|
||||
public IConnectionFactory ConnectionFactory
|
||||
@@ -75,17 +75,17 @@ namespace Spring.Messaging.Nms
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a NmsTemplate for the given ConnectionFactory.
|
||||
/// Creates a MessageTemplate for the given ConnectionFactory.
|
||||
/// </summary>
|
||||
/// <remarks>Only invoked if populating the gateway with a ConnectionFactory reference.
|
||||
/// Can be overridden in subclasses to provide a different NmsTemplate instance
|
||||
/// Can be overridden in subclasses to provide a different MessageTemplate instance
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="connectionFactory">The connection factory.</param>
|
||||
/// <returns></returns>
|
||||
protected virtual NmsTemplate CreateNmsTemplate(IConnectionFactory connectionFactory)
|
||||
protected virtual MessageTemplate CreateNmsTemplate(IConnectionFactory connectionFactory)
|
||||
{
|
||||
return new NmsTemplate(connectionFactory);
|
||||
return new MessageTemplate(connectionFactory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,11 +47,11 @@ namespace Spring.Messaging.Nms
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class NmsTemplate : NmsDestinationAccessor, INmsOperations
|
||||
public class MessageTemplate : MessageDestinationAccessor, IMessageOperations
|
||||
{
|
||||
#region Logging
|
||||
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(NmsTemplate));
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(MessageTemplate));
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -63,7 +63,7 @@ namespace Spring.Messaging.Nms
|
||||
/// </summary>
|
||||
public static readonly long DEFAULT_RECEIVE_TIMEOUT = -1;
|
||||
|
||||
private NmsTemplateResourceFactory transactionalResourceFactory;
|
||||
private MessageTemplateResourceFactory transactionalResourceFactory;
|
||||
|
||||
private object defaultDestination;
|
||||
|
||||
@@ -85,30 +85,28 @@ namespace Spring.Messaging.Nms
|
||||
private bool persistent = NMSConstants.defaultPersistence;
|
||||
|
||||
private TimeSpan timeToLive;
|
||||
|
||||
private NmsResources jmsResources = new NmsResources();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor (s)
|
||||
|
||||
/// <summary> Create a new NmsTemplate.</summary>
|
||||
/// <summary> Create a new MessageTemplate.</summary>
|
||||
/// <remarks>
|
||||
/// <para>Note: The ConnectionFactory has to be set before using the instance.
|
||||
/// This constructor can be used to prepare a NmsTemplate via an ObjectFactory,
|
||||
/// This constructor can be used to prepare a MessageTemplate via an ObjectFactory,
|
||||
/// typically setting the ConnectionFactory.</para>
|
||||
/// </remarks>
|
||||
public NmsTemplate()
|
||||
public MessageTemplate()
|
||||
{
|
||||
transactionalResourceFactory = new NmsTemplateResourceFactory(this);
|
||||
transactionalResourceFactory = new MessageTemplateResourceFactory(this);
|
||||
InitDefaultStrategies();
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Create a new NmsTemplate, given a ConnectionFactory.</summary>
|
||||
/// <summary> Create a new MessageTemplate, given a ConnectionFactory.</summary>
|
||||
/// <param name="connectionFactory">the ConnectionFactory to obtain IConnections from
|
||||
/// </param>
|
||||
public NmsTemplate(IConnectionFactory connectionFactory)
|
||||
public MessageTemplate(IConnectionFactory connectionFactory)
|
||||
: this()
|
||||
{
|
||||
ConnectionFactory = connectionFactory;
|
||||
@@ -132,7 +130,7 @@ namespace Spring.Messaging.Nms
|
||||
if (defaultDestination == null)
|
||||
{
|
||||
throw new SystemException(
|
||||
"No defaultDestination or defaultDestinationName specified. Check configuration of NmsTemplate.");
|
||||
"No defaultDestination or defaultDestinationName specified. Check configuration of MessageTemplate.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +139,7 @@ namespace Spring.Messaging.Nms
|
||||
{
|
||||
if (MessageConverter == null)
|
||||
{
|
||||
throw new SystemException("No messageConverter registered. Check configuration of NmsTemplate.");
|
||||
throw new SystemException("No messageConverter registered. Check configuration of MessageTemplate.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +188,7 @@ namespace Spring.Messaging.Nms
|
||||
}
|
||||
finally
|
||||
{
|
||||
NmsUtils.CloseSession(sessionToClose);
|
||||
MessagingUtils.CloseSession(sessionToClose);
|
||||
ConnectionFactoryUtils.ReleaseConnection(conToClose, ConnectionFactory, startConnection);
|
||||
}
|
||||
}
|
||||
@@ -371,26 +369,26 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
#region NMS Factory Methods
|
||||
|
||||
/// <summary> Fetch an appropriate Connection from the given NmsResourceHolder.
|
||||
/// <summary> Fetch an appropriate Connection from the given MessageResourceHolder.
|
||||
/// </summary>
|
||||
/// <param name="holder">the NmsResourceHolder
|
||||
/// <param name="holder">the MessageResourceHolder
|
||||
/// </param>
|
||||
/// <returns> an appropriate IConnection fetched from the holder,
|
||||
/// or <code>null</code> if none found
|
||||
/// </returns>
|
||||
protected virtual IConnection GetConnection(NmsResourceHolder holder)
|
||||
protected virtual IConnection GetConnection(MessageResourceHolder holder)
|
||||
{
|
||||
return holder.GetConnection();
|
||||
}
|
||||
|
||||
/// <summary> Fetch an appropriate Session from the given NmsResourceHolder.
|
||||
/// <summary> Fetch an appropriate Session from the given MessageResourceHolder.
|
||||
/// </summary>
|
||||
/// <param name="holder">the NmsResourceHolder
|
||||
/// <param name="holder">the MessageResourceHolder
|
||||
/// </param>
|
||||
/// <returns> an appropriate ISession fetched from the holder,
|
||||
/// or <code>null</code> if none found
|
||||
/// </returns>
|
||||
protected virtual ISession GetSession(NmsResourceHolder holder)
|
||||
protected virtual ISession GetSession(MessageResourceHolder holder)
|
||||
{
|
||||
return holder.GetSession();
|
||||
}
|
||||
@@ -550,12 +548,12 @@ namespace Spring.Messaging.Nms
|
||||
if (session.Transacted && IsSessionLocallyTransacted(session))
|
||||
{
|
||||
// Transacted session created by this template -> commit.
|
||||
NmsUtils.CommitIfNecessary(session);
|
||||
MessagingUtils.CommitIfNecessary(session);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
NmsUtils.CloseMessageProducer(producer);
|
||||
MessagingUtils.CloseMessageProducer(producer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +579,7 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
#endregion
|
||||
|
||||
#region INmsOperations Implementation
|
||||
#region IMessageOperations Implementation
|
||||
|
||||
/// <summary> Execute the action specified by the given action object within
|
||||
/// a NMS Session.
|
||||
@@ -952,8 +950,8 @@ namespace Spring.Messaging.Nms
|
||||
try
|
||||
{
|
||||
long timeout = ReceiveTimeout;
|
||||
NmsResourceHolder resourceHolder =
|
||||
(NmsResourceHolder)TransactionSynchronizationManager.GetResource(ConnectionFactory);
|
||||
MessageResourceHolder resourceHolder =
|
||||
(MessageResourceHolder)TransactionSynchronizationManager.GetResource(ConnectionFactory);
|
||||
if (resourceHolder != null && resourceHolder.HasTimeout)
|
||||
{
|
||||
timeout = Convert.ToInt64(resourceHolder.TimeToLiveInMilliseconds);
|
||||
@@ -967,7 +965,7 @@ namespace Spring.Messaging.Nms
|
||||
if (IsSessionLocallyTransacted(session))
|
||||
{
|
||||
// Transacted session created by this template -> commit.
|
||||
NmsUtils.CommitIfNecessary(session);
|
||||
MessagingUtils.CommitIfNecessary(session);
|
||||
}
|
||||
}
|
||||
else if (IsClientAcknowledge(session))
|
||||
@@ -982,7 +980,7 @@ namespace Spring.Messaging.Nms
|
||||
}
|
||||
finally
|
||||
{
|
||||
NmsUtils.CloseMessageConsumer(consumer);
|
||||
MessagingUtils.CloseMessageConsumer(consumer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1106,31 +1104,31 @@ namespace Spring.Messaging.Nms
|
||||
/// <summary>
|
||||
/// ResourceFactory implementation that delegates to this template's callback methods.
|
||||
/// </summary>
|
||||
private class NmsTemplateResourceFactory : ConnectionFactoryUtils.ResourceFactory
|
||||
private class MessageTemplateResourceFactory : ConnectionFactoryUtils.ResourceFactory
|
||||
{
|
||||
private NmsTemplate enclosingTemplateInstance;
|
||||
private MessageTemplate enclosingTemplateInstance;
|
||||
|
||||
public NmsTemplateResourceFactory(NmsTemplate enclosingInstance)
|
||||
public MessageTemplateResourceFactory(MessageTemplate enclosingInstance)
|
||||
{
|
||||
InitBlock(enclosingInstance);
|
||||
}
|
||||
|
||||
private void InitBlock(NmsTemplate enclosingInstance)
|
||||
private void InitBlock(MessageTemplate enclosingInstance)
|
||||
{
|
||||
enclosingTemplateInstance = enclosingInstance;
|
||||
}
|
||||
|
||||
public NmsTemplate EnclosingInstance
|
||||
public MessageTemplate EnclosingInstance
|
||||
{
|
||||
get { return enclosingTemplateInstance; }
|
||||
}
|
||||
|
||||
public virtual IConnection GetConnection(NmsResourceHolder holder)
|
||||
public virtual IConnection GetConnection(MessageResourceHolder holder)
|
||||
{
|
||||
return EnclosingInstance.GetConnection(holder);
|
||||
}
|
||||
|
||||
public virtual ISession GetSession(NmsResourceHolder holder)
|
||||
public virtual ISession GetSession(MessageResourceHolder holder)
|
||||
{
|
||||
return EnclosingInstance.GetSession(holder);
|
||||
}
|
||||
@@ -1153,10 +1151,10 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
private class ProducerCreatorCallback : ISessionCallback
|
||||
{
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private IProducerCallback producerCallback;
|
||||
|
||||
public ProducerCreatorCallback(NmsTemplate jmsTemplate, IProducerCallback producerCallback)
|
||||
public ProducerCreatorCallback(MessageTemplate jmsTemplate, IProducerCallback producerCallback)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.producerCallback = producerCallback;
|
||||
@@ -1171,7 +1169,7 @@ namespace Spring.Messaging.Nms
|
||||
}
|
||||
finally
|
||||
{
|
||||
NmsUtils.CloseMessageProducer(producer);
|
||||
MessagingUtils.CloseMessageProducer(producer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1179,18 +1177,18 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
private class ReceiveCallback : ISessionCallback
|
||||
{
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private IDestination destination;
|
||||
private string destinationName;
|
||||
|
||||
|
||||
public ReceiveCallback(NmsTemplate jmsTemplate, string destinationName)
|
||||
public ReceiveCallback(MessageTemplate jmsTemplate, string destinationName)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destinationName = destinationName;
|
||||
}
|
||||
|
||||
public ReceiveCallback(NmsTemplate jmsTemplate, IDestination destination)
|
||||
public ReceiveCallback(MessageTemplate jmsTemplate, IDestination destination)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destination = destination;
|
||||
@@ -1214,11 +1212,11 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
private class ConvertAndSendMessageCreator : IMessageCreator
|
||||
{
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private object objectToConvert;
|
||||
private IMessagePostProcessor messagePostProcessor;
|
||||
|
||||
public ConvertAndSendMessageCreator(NmsTemplate jmsTemplate, object message, IMessagePostProcessor messagePostProcessor)
|
||||
public ConvertAndSendMessageCreator(MessageTemplate jmsTemplate, object message, IMessagePostProcessor messagePostProcessor)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
objectToConvert = message;
|
||||
@@ -1234,12 +1232,12 @@ namespace Spring.Messaging.Nms
|
||||
|
||||
private class ReceiveSelectedCallback : ISessionCallback
|
||||
{
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private string messageSelector;
|
||||
private string destinationName;
|
||||
private IDestination destination;
|
||||
|
||||
public ReceiveSelectedCallback(NmsTemplate jmsTemplate,
|
||||
public ReceiveSelectedCallback(MessageTemplate jmsTemplate,
|
||||
IDestination destination,
|
||||
string messageSelector)
|
||||
{
|
||||
@@ -1247,7 +1245,7 @@ namespace Spring.Messaging.Nms
|
||||
this.destination = destination;
|
||||
this.messageSelector = messageSelector;
|
||||
}
|
||||
public ReceiveSelectedCallback(NmsTemplate jmsTemplate,
|
||||
public ReceiveSelectedCallback(MessageTemplate jmsTemplate,
|
||||
string destinationName,
|
||||
string messageSelector)
|
||||
{
|
||||
@@ -1276,42 +1274,12 @@ namespace Spring.Messaging.Nms
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a TIBCO specific class so that we can reuse connections, session, and
|
||||
/// message producers instead of creating/destroying them on each operation.
|
||||
/// </summary>
|
||||
internal class NmsResources
|
||||
{
|
||||
private IConnection connection;
|
||||
private ISession session;
|
||||
private IMessageProducer messageProducer;
|
||||
|
||||
public IConnection Connection
|
||||
{
|
||||
get { return connection; }
|
||||
set { connection = value; }
|
||||
}
|
||||
|
||||
public ISession Session
|
||||
{
|
||||
get { return session; }
|
||||
set { session = value; }
|
||||
}
|
||||
|
||||
public IMessageProducer MessageProducer
|
||||
{
|
||||
get { return messageProducer; }
|
||||
set { messageProducer = value; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class SimpleMessageCreator : IMessageCreator
|
||||
{
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private object objectToConvert;
|
||||
|
||||
public SimpleMessageCreator(NmsTemplate jmsTemplate, object objectToConvert)
|
||||
public SimpleMessageCreator(MessageTemplate jmsTemplate, object objectToConvert)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.objectToConvert = objectToConvert;
|
||||
@@ -1331,32 +1299,32 @@ namespace Spring.Messaging.Nms
|
||||
{
|
||||
private string destinationName;
|
||||
private IDestination destination;
|
||||
private NmsTemplate jmsTemplate;
|
||||
private MessageTemplate jmsTemplate;
|
||||
private IMessageCreator messageCreator;
|
||||
private IMessageCreatorDelegate messageCreatorDelegate;
|
||||
|
||||
public SendDestinationCallback(NmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
|
||||
public SendDestinationCallback(MessageTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destinationName = destinationName;
|
||||
this.messageCreator = messageCreator;
|
||||
}
|
||||
|
||||
public SendDestinationCallback(NmsTemplate jmsTemplate, IDestination destination, IMessageCreator messageCreator)
|
||||
public SendDestinationCallback(MessageTemplate jmsTemplate, IDestination destination, IMessageCreator messageCreator)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destination = destination;
|
||||
this.messageCreator = messageCreator;
|
||||
}
|
||||
|
||||
public SendDestinationCallback(NmsTemplate jmsTemplate, string destinationName, IMessageCreatorDelegate messageCreatorDelegate)
|
||||
public SendDestinationCallback(MessageTemplate jmsTemplate, string destinationName, IMessageCreatorDelegate messageCreatorDelegate)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destinationName = destinationName;
|
||||
this.messageCreatorDelegate = messageCreatorDelegate;
|
||||
}
|
||||
|
||||
public SendDestinationCallback(NmsTemplate jmsTemplate, IDestination destination, IMessageCreatorDelegate messageCreatorDelegate)
|
||||
public SendDestinationCallback(MessageTemplate jmsTemplate, IDestination destination, IMessageCreatorDelegate messageCreatorDelegate)
|
||||
{
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
this.destination = destination;
|
||||
@@ -26,7 +26,7 @@ using Apache.NMS;
|
||||
namespace Spring.Messaging.Nms.Support.Converter
|
||||
{
|
||||
/// <summary> A simple message converter that can handle ITextMessages, IBytesMessages,
|
||||
/// IMapMessages, and IObjectMessages. Used as default by NmsTemplate, for
|
||||
/// IMapMessages, and IObjectMessages. Used as default by MessageTemplate, for
|
||||
/// <code>ConvertAndSend</code> and <code>ReceiveAndConvert</code> operations.
|
||||
///
|
||||
/// <p>Converts a String to a NMS ITextMessage, a byte array to a NMS IBytesMessage,
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace Spring.Messaging.Nms.Support.IDestinations
|
||||
/// <summary> Strategy interface for resolving NMS destinations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Used by NmsTemplate for resolving
|
||||
/// <para>Used by MessageTemplate for resolving
|
||||
/// destination names from simple Strings to actual
|
||||
/// IDestination implementation instances.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>The default DestinationResolver implementation used by
|
||||
/// NmsTemplate instances is the
|
||||
/// MessageTemplate instances is the
|
||||
/// DynamicDestinationResolver class. Consider using the
|
||||
/// JndiDestinationResolver for more advanced scenarios.
|
||||
/// </para>
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using Spring.Objects.Factory;
|
||||
using Spring.Util;
|
||||
using Apache.NMS;
|
||||
|
||||
namespace Spring.Messaging.Nms.Support.IDestinations
|
||||
{
|
||||
/// <summary> Base class for NmsTemplate} and other
|
||||
/// NMS-accessing gateway helpers, adding destination-related properties to
|
||||
/// NmsAccessor's common properties.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <p>Not intended to be used directly. See NmsTemplate.</p>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <author>Juergen Hoeller </author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class NmsDestinationAccessor : NmsAccessor
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IDestinationResolver destinationResolver = new DynamicDestinationResolver();
|
||||
|
||||
private bool pubSubDomain = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the destination resolver that is to be used to resolve
|
||||
/// IDestination references for this accessor.
|
||||
/// </summary>
|
||||
/// <remarks>The default resolver is a DynamicDestinationResolver. Specify a
|
||||
/// JndiDestinationResolver for resolving destination names as JNDI locations.
|
||||
/// </remarks>
|
||||
/// <value>The destination resolver.</value>
|
||||
virtual public IDestinationResolver DestinationResolver
|
||||
{
|
||||
get
|
||||
{
|
||||
return destinationResolver;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
AssertUtils.ArgumentNotNull(value, "DestinationResolver must not be null");
|
||||
this.destinationResolver = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether Publish/Subscribe
|
||||
/// domain (Topics) is used. Otherwise, the Point-to-Point domain
|
||||
/// (Queues) is used.
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>this
|
||||
/// setting tells what type of destination to create if dynamic destinations are enabled.</remarks>
|
||||
/// <value><c>true</c> if Publish/Subscribe domain; otherwise, <c>false</c>
|
||||
/// for the Point-to-Point domain.</value>
|
||||
public virtual bool PubSubDomain
|
||||
{
|
||||
get
|
||||
{
|
||||
return pubSubDomain;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.pubSubDomain = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the given destination name to a NMS destination.
|
||||
/// </summary>
|
||||
/// <param name="session">The current session.</param>
|
||||
/// <param name="destinationName">Name of the destination.</param>
|
||||
/// <returns>The located IDestination</returns>
|
||||
/// <exception cref="NMSException">If resolution failed.</exception>
|
||||
public virtual IDestination ResolveDestinationName(ISession session, System.String destinationName)
|
||||
{
|
||||
return DestinationResolver.ResolveDestinationName(session, destinationName, PubSubDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,20 +25,20 @@ using Apache.NMS;
|
||||
|
||||
namespace Spring.Messaging.Nms.Support
|
||||
{
|
||||
/// <summary> Base class for NmsTemplate and other NMS-accessing gateway helpers</summary>
|
||||
/// <summary> Base class for MessageTemplate and other NMS-accessing gateway helpers</summary>
|
||||
/// <remarks>It defines common properties like the ConnectionFactory}. The subclass
|
||||
/// NmsIDestinationAccessor adds further, destination-related properties.
|
||||
/// <para>
|
||||
/// Not intended to be used directly. See NmsTemplate.
|
||||
/// Not intended to be used directly. See MessageTemplate.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class NmsAccessor : IInitializingObject
|
||||
public class MessagingAccessor : IInitializingObject
|
||||
{
|
||||
#region Logging
|
||||
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(NmsAccessor));
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(MessagingAccessor));
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace Spring.Messaging.Nms.Support
|
||||
/// Generic utility methods for working with NMS. Mainly for internal use
|
||||
/// within the framework, but also useful for custom NMS access code.
|
||||
/// </summary>
|
||||
public abstract class NmsUtils
|
||||
public abstract class MessagingUtils
|
||||
{
|
||||
#region Logging
|
||||
|
||||
private static readonly ILog logger = LogManager.GetLogger(typeof(NmsUtils));
|
||||
private static readonly ILog logger = LogManager.GetLogger(typeof(MessagingUtils));
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -54,34 +54,34 @@
|
||||
<Compile Include="Messaging\Nms\Connections\ConnectionFactoryUtils.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\IDecoratorSession.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\ISmartConnectionFactory.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\NmsResourceHolder.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\NmsTransactionManager.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\MessageResourceHolder.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\MessageTransactionManager.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\SingleConnectionFactory.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\SynchedLocalTransactionFailedException.cs" />
|
||||
<Compile Include="Messaging\Nms\IExceptionListener.cs" />
|
||||
<Compile Include="Messaging\Nms\IMessageCreator.cs" />
|
||||
<Compile Include="Messaging\Nms\IMessageListener.cs" />
|
||||
<Compile Include="Messaging\Nms\IMessageOperations.cs" />
|
||||
<Compile Include="Messaging\Nms\IMessagePostProcessor.cs" />
|
||||
<Compile Include="Messaging\Nms\INmsOperations.cs" />
|
||||
<Compile Include="Messaging\Nms\IProducerCallback.cs" />
|
||||
<Compile Include="Messaging\Nms\ISessionCallback.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\AbstractListenerContainer.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\AbstractMessageListenerContainer.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\AbstractNmsListeningContainer.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\Adapter\MessageListenerAdapter.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\ISessionAwareMessageListener.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\LocallyExposedNmsResourceHolder.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\LocallyExposedMessageResourceHolder.cs" />
|
||||
<Compile Include="Messaging\Nms\Listener\SimpleMessageListenerContainer.cs" />
|
||||
<Compile Include="Messaging\Nms\MessageCreatorDelegate.cs" />
|
||||
<Compile Include="Messaging\Nms\NmsGatewaySupport.cs" />
|
||||
<Compile Include="Messaging\Nms\NmsTemplate.cs" />
|
||||
<Compile Include="Messaging\Nms\MessageGatewaySupport.cs" />
|
||||
<Compile Include="Messaging\Nms\MessageTemplate.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Converter\IMessageConverter.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Converter\MessageConversionException.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Converter\SimpleMessageConverter.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Destinations\DynamicDestinationResolver.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Destinations\IDestinationResolver.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Destinations\NmsDestinationAccessor.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\NmsAccessor.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\NmsUtils.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\Destinations\MessageDestinationAccessor.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\MessageAccessor.cs" />
|
||||
<Compile Include="Messaging\Nms\Support\MessageUtils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Spring.Aop\Spring.Aop.2005.csproj">
|
||||
|
||||
@@ -62,9 +62,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
nt.Execute(new AssertSessionCallback(session));
|
||||
tm.Commit(ts);
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
nt.Execute(new AssertSessionCallback(session));
|
||||
tm.Rollback(ts);
|
||||
|
||||
@@ -111,9 +111,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
mocks.ReplayAll();
|
||||
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
nt.Execute(new AssertSessionCallback(session));
|
||||
|
||||
TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
@@ -143,9 +143,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
nt.Execute(new AssertSessionCallback(session));
|
||||
|
||||
TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
@@ -192,9 +192,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
nt.Execute(new AssertSessionCallback(session));
|
||||
|
||||
TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
@@ -241,9 +241,9 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
mocks.ReplayAll();
|
||||
|
||||
NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
|
||||
MessageTransactionManager tm = new MessageTransactionManager(connectionFactory);
|
||||
ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
|
||||
NmsTemplate nt = new NmsTemplate(connectionFactory);
|
||||
MessageTemplate nt = new MessageTemplate(connectionFactory);
|
||||
|
||||
|
||||
TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
@@ -50,11 +50,11 @@ namespace Spring.Messaging.Nms.Integration
|
||||
Assert.IsNotNull(listener);
|
||||
|
||||
|
||||
NmsTemplate nmsTemplate = (NmsTemplate) applicationContext["NmsTemplate"] as NmsTemplate;
|
||||
Assert.IsNotNull(nmsTemplate);
|
||||
MessageTemplate messageTemplate = (MessageTemplate) applicationContext["MessageTemplate"] as MessageTemplate;
|
||||
Assert.IsNotNull(messageTemplate);
|
||||
|
||||
Assert.AreEqual(0, listener.MessageCount);
|
||||
nmsTemplate.ConvertAndSend("Hello World 1");
|
||||
messageTemplate.ConvertAndSend("Hello World 1");
|
||||
|
||||
int waitInMillis = 2000;
|
||||
Thread.Sleep(waitInMillis);
|
||||
@@ -62,7 +62,7 @@ namespace Spring.Messaging.Nms.Integration
|
||||
|
||||
container.Stop();
|
||||
Console.WriteLine("container stopped.");
|
||||
nmsTemplate.ConvertAndSend("Hello World 2");
|
||||
messageTemplate.ConvertAndSend("Hello World 2");
|
||||
Thread.Sleep(waitInMillis);
|
||||
Assert.AreEqual(1, listener.MessageCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user