You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by mi...@apache.org on 2021/02/05 19:22:28 UTC

[activemq-nms-api] branch master updated: AMQNET-637 NMS 2.0 More async methods

This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-nms-api.git


The following commit(s) were added to refs/heads/master by this push:
     new d045738  AMQNET-637 NMS 2.0 More async methods
     new 1852cf7  Merge pull request #18 from lukeabsent/AMQNET-637
d045738 is described below

commit d045738829aaf8dda169b8cb0afacbe2c856307a
Author: lukeabsent <tr...@interia.pl>
AuthorDate: Fri Feb 5 14:41:44 2021 +0100

    AMQNET-637 NMS 2.0 More async methods
---
 src/nms-api/IConnection.cs          |  16 ++++
 src/nms-api/IConnectionFactory.cs   |  32 +++++++-
 src/nms-api/IMessageConsumer.cs     |  20 +++++
 src/nms-api/IMessageProducer.cs     |   5 ++
 src/nms-api/INMSConsumer.cs         |  23 ++++++
 src/nms-api/INMSContext.cs          | 145 ++++++++++++++++++++++++++++++++-
 src/nms-api/INMSProducer.cs         |   5 ++
 src/nms-api/INetTxConnection.cs     |  16 ++++
 src/nms-api/INetTxSession.cs        |  10 +++
 src/nms-api/IQueueBrowser.cs        |  10 +++
 src/nms-api/ISession.cs             | 155 ++++++++++++++++++++++++++++++++++++
 src/nms-api/IStartable.cs           |   5 ++
 src/nms-api/IStoppable.cs           |   4 +
 src/nms-api/NMSConnectionFactory.cs |  31 ++++++++
 14 files changed, 472 insertions(+), 5 deletions(-)

diff --git a/src/nms-api/IConnection.cs b/src/nms-api/IConnection.cs
index 7d1f057..5a0b0fb 100644
--- a/src/nms-api/IConnection.cs
+++ b/src/nms-api/IConnection.cs
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading.Tasks;
 
 namespace Apache.NMS
 {
@@ -101,9 +102,24 @@ namespace Apache.NMS
         ISession CreateSession(AcknowledgementMode acknowledgementMode);
 
         /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        Task<ISession> CreateSessionAsync();
+
+        /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        Task<ISession> CreateSessionAsync(AcknowledgementMode acknowledgementMode);
+        
+        /// <summary>
         /// Closes the connection.
         /// </summary>
         void Close();
+        
+        /// <summary>
+        /// Closes the connection.
+        /// </summary>
+        Task CloseAsync();
 
         /// <summary>
         /// An asynchronous listener which can be notified if an error occurs
diff --git a/src/nms-api/IConnectionFactory.cs b/src/nms-api/IConnectionFactory.cs
index c77e8e7..07f5c22 100644
--- a/src/nms-api/IConnectionFactory.cs
+++ b/src/nms-api/IConnectionFactory.cs
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading.Tasks;
 
 namespace Apache.NMS
 {
@@ -32,9 +33,19 @@ namespace Apache.NMS
         /// <summary>
         /// Creates a new connection with the given user name and password
         /// </summary>
-        IConnection CreateConnection(string userName, string password);
+        IConnection CreateConnection(string userName, string password); 
+        
+        /// <summary>
+        /// Creates a new connection
+        /// </summary>
+        Task<IConnection> CreateConnectionAsync();
 
         /// <summary>
+        /// Creates a new connection with the given user name and password
+        /// </summary>
+        Task<IConnection> CreateConnectionAsync(string userName, string password);
+        
+        /// <summary>
         /// Creates a new context
         /// </summary>
         INMSContext CreateContext();
@@ -53,7 +64,26 @@ namespace Apache.NMS
         /// Creates a new context with the given user name, password and acknowledgement mode
         /// </summary>
         INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode);
+        
+        /// <summary>
+        /// Creates a new context
+        /// </summary>
+        Task<INMSContext> CreateContextAsync();
+
+        /// <summary>
+        /// Creates a new context with the given acknowledgement mode.
+        /// </summary>
+        Task<INMSContext> CreateContextAsync(AcknowledgementMode acknowledgementMode);
+
+        /// <summary>
+        /// Creates a new context with the given user name and password
+        /// </summary>
+        Task<INMSContext> CreateContextAsync(string userName, string password);
 
+        /// <summary>
+        /// Creates a new context with the given user name, password and acknowledgement mode
+        /// </summary>
+        Task<INMSContext> CreateContextAsync(string userName, string password, AcknowledgementMode acknowledgementMode);
 
         /// <summary>
         /// Get/or set the broker Uri.
diff --git a/src/nms-api/IMessageConsumer.cs b/src/nms-api/IMessageConsumer.cs
index c93d857..95a3780 100644
--- a/src/nms-api/IMessageConsumer.cs
+++ b/src/nms-api/IMessageConsumer.cs
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+using System.Threading.Tasks;
+
 namespace Apache.NMS
 {
     /// <summary>
@@ -42,11 +44,21 @@ namespace Apache.NMS
         /// Waits until a message is available and returns it
         /// </summary>
         IMessage Receive();
+        
+        /// <summary>
+        /// Waits until a message is available and returns it
+        /// </summary>
+        Task<IMessage> ReceiveAsync();
 
         /// <summary>
         /// If a message is available within the timeout duration it is returned otherwise this method returns null
         /// </summary>
         IMessage Receive(System.TimeSpan timeout);
+        
+        /// <summary>
+        /// If a message is available within the timeout duration it is returned otherwise this method returns null
+        /// </summary>
+        Task<IMessage> ReceiveAsync(System.TimeSpan timeout);
 
         /// <summary>
         /// Receives the next message if one is immediately available for delivery on the client side
@@ -70,6 +82,14 @@ namespace Apache.NMS
         /// A blocked message consumer receive call returns null when this message consumer is closed.
         /// </remarks>
         void Close();
+        
+        /// <summary>
+        /// Closes the message consumer.
+        /// </summary>
+        /// <remarks>
+        /// Clients should close message consumers when they are not needed.
+        /// </remarks>
+        Task CloseAsync();
 
         /// <summary>
         /// A Delegate that is called each time a Message is dispatched to allow the client to do
diff --git a/src/nms-api/IMessageProducer.cs b/src/nms-api/IMessageProducer.cs
index 52de6f7..38f3b05 100644
--- a/src/nms-api/IMessageProducer.cs
+++ b/src/nms-api/IMessageProducer.cs
@@ -86,6 +86,11 @@ namespace Apache.NMS
         void Close();
 
         /// <summary>
+        /// Close the producer.
+        /// </summary>
+        Task CloseAsync();
+
+        /// <summary>
         /// A delegate that is called each time a Message is sent from this Producer which allows
         /// the application to perform any needed transformations on the Message before it is sent.
         /// </summary>
diff --git a/src/nms-api/INMSConsumer.cs b/src/nms-api/INMSConsumer.cs
index e9f8f59..89f3ed6 100644
--- a/src/nms-api/INMSConsumer.cs
+++ b/src/nms-api/INMSConsumer.cs
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading.Tasks;
 
 namespace Apache.NMS
 {
@@ -29,11 +30,21 @@ namespace Apache.NMS
         /// Waits until a message is available and returns it
         /// </summary>
         IMessage Receive();
+        
+        /// <summary>
+        /// Waits until a message is available and returns it
+        /// </summary>
+        Task<IMessage> ReceiveAsync();
 
         /// <summary>
         /// If a message is available within the timeout duration it is returned otherwise this method returns null
         /// </summary>
         IMessage Receive(TimeSpan timeout);
+        
+        /// <summary>
+        /// If a message is available within the timeout duration it is returned otherwise this method returns null
+        /// </summary>
+        Task<IMessage> ReceiveAsync(TimeSpan timeout);
 
         /// <summary>
         /// Receives the next message if one is immediately available for delivery on the client side
@@ -45,8 +56,12 @@ namespace Apache.NMS
 
 
         T ReceiveBody<T>();
+        
+        Task<T> ReceiveBodyAsync<T>();
 
         T ReceiveBody<T>(TimeSpan timeout);
+        
+        Task<T> ReceiveBodyAsync<T>(TimeSpan timeout);
 
         T ReceiveBodyNoWait<T>();
 
@@ -68,6 +83,14 @@ namespace Apache.NMS
         void Close();
 
         /// <summary>
+        /// Closes the message consumer.
+        /// </summary>
+        /// <remarks>
+        /// Clients should close message consumers when they are not needed.
+        /// </remarks>
+        Task CloseAsync();
+
+        /// <summary>
         /// A Delegate that is called each time a Message is dispatched to allow the client to do
         /// any necessary transformations on the received message before it is delivered.
         /// </summary>
diff --git a/src/nms-api/INMSContext.cs b/src/nms-api/INMSContext.cs
index 64b0be3..5be6317 100644
--- a/src/nms-api/INMSContext.cs
+++ b/src/nms-api/INMSContext.cs
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading.Tasks;
 
 namespace Apache.NMS
 {
@@ -34,7 +35,11 @@ namespace Apache.NMS
         /// Creates a producer of messages
         /// </summary>
         INMSProducer CreateProducer();
-
+        
+        /// <summary>
+        /// Creates a producer of messages
+        /// </summary>
+        Task<INMSProducer> CreateProducerAsync();
 
         /// <summary>
         /// Creates a consumer of messages on a given destination
@@ -67,9 +72,43 @@ namespace Apache.NMS
         INMSConsumer CreateSharedDurableConsumer(ITopic destination, string subscriptionName);
 
         INMSConsumer CreateSharedDurableConsumer(ITopic destination, string subscriptionName, string selector);
+        
+        /// <summary>
+        /// Creates a consumer of messages on a given destination
+        /// </summary>
+        Task<INMSConsumer> CreateConsumerAsync(IDestination destination);
+
+        /// <summary>
+        /// Creates a consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<INMSConsumer> CreateConsumerAsync(IDestination destination, string selector);
+
+        /// <summary>
+        /// Creates a consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<INMSConsumer> CreateConsumerAsync(IDestination destination, string selector, bool noLocal);
+
+        Task<INMSConsumer> CreateDurableConsumerAsync(ITopic destination, string subscriptionName);
+
+        Task<INMSConsumer> CreateDurableConsumerAsync(ITopic destination, string subscriptionName, string selector);
 
+        /// <summary>
+        /// Creates a named durable consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<INMSConsumer> CreateDurableConsumerAsync(ITopic destination, string subscriptionName, string selector, bool noLocal);
+
+        Task<INMSConsumer> CreateSharedConsumerAsync(ITopic destination, string subscriptionName);
+
+        Task<INMSConsumer> CreateSharedConsumerAsync(ITopic destination, string subscriptionName, string selector);
+
+        Task<INMSConsumer> CreateSharedDurableConsumerAsync(ITopic destination, string subscriptionName);
+
+        Task<INMSConsumer> CreateSharedDurableConsumerAsync(ITopic destination, string subscriptionName, string selector);
+        
 
         void Unsubscribe(string name);
+        
+        Task UnsubscribeAsync(string name);
 
         /// <summary>
         /// Creates a QueueBrowser object to peek at the messages on the specified queue.
@@ -83,8 +122,22 @@ namespace Apache.NMS
         /// <exception cref="System.NotSupportedException">
         /// If the Prodiver does not support creation of Queue Browsers.
         /// </exception>
-        IQueueBrowser CreateBrowser(IQueue queue);
-
+        IQueueBrowser CreateBrowser(IQueue queue);  
+        
+        /// <summary>
+        /// Creates a QueueBrowser object to peek at the messages on the specified queue.
+        /// </summary>
+        /// <param name="queue">
+        /// A <see cref="IQueue"/>
+        /// </param>
+        /// <returns>
+        /// A <see cref="IQueueBrowser"/>
+        /// </returns>
+        /// <exception cref="System.NotSupportedException">
+        /// If the Prodiver does not support creation of Queue Browsers.
+        /// </exception>
+        Task<IQueueBrowser> CreateBrowserAsync(IQueue queue);
+        
         /// <summary>
         /// Creates a QueueBrowser object to peek at the messages on the specified queue
         /// using a message selector.
@@ -102,26 +155,64 @@ namespace Apache.NMS
         /// If the Prodiver does not support creation of Queue Browsers.
         /// </exception>
         IQueueBrowser CreateBrowser(IQueue queue, string selector);
-
+        
+        /// <summary>
+        /// Creates a QueueBrowser object to peek at the messages on the specified queue
+        /// using a message selector.
+        /// </summary>
+        /// <param name="queue">
+        /// A <see cref="IQueue"/>
+        /// </param>
+        /// <param name="selector">
+        /// A <see cref="System.String"/>
+        /// </param>
+        /// <returns>
+        /// A <see cref="IQueueBrowser"/>
+        /// </returns>
+        /// <exception cref="System.NotSupportedException">
+        /// If the Prodiver does not support creation of Queue Browsers.
+        /// </exception>
+        Task<IQueueBrowser> CreateBrowserAsync(IQueue queue, string selector);
+        
         /// <summary>
         /// Returns the queue for the given name
         /// </summary>
         IQueue GetQueue(string name);
+        
+        /// <summary>
+        /// Returns the queue for the given name
+        /// </summary>
+        Task<IQueue> GetQueueAsync(string name);
 
         /// <summary>
         /// Returns the topic for the given name
         /// </summary>
         ITopic GetTopic(string name);
+        
+        /// <summary>
+        /// Returns the topic for the given name
+        /// </summary>
+        Task<ITopic> GetTopicAsync(string name);
 
         /// <summary>
         /// Creates a temporary queue
         /// </summary>
         ITemporaryQueue CreateTemporaryQueue();
+        
+        /// <summary>
+        /// Creates a temporary queue
+        /// </summary>
+        Task<ITemporaryQueue> CreateTemporaryQueueAsync();
 
         /// <summary>
         /// Creates a temporary topic
         /// </summary>
         ITemporaryTopic CreateTemporaryTopic();
+        
+        /// <summary>
+        /// Creates a temporary topic
+        /// </summary>
+        Task<ITemporaryTopic> CreateTemporaryTopicAsync();
 
         // Factory methods to create messages
 
@@ -131,45 +222,91 @@ namespace Apache.NMS
         IMessage CreateMessage();
 
         /// <summary>
+        /// Creates a new message with an empty body
+        /// </summary>
+        Task<IMessage> CreateMessageAsync();
+
+        /// <summary>
         /// Creates a new text message with an empty body
         /// </summary>
         ITextMessage CreateTextMessage();
 
         /// <summary>
+        /// Creates a new text message with an empty body
+        /// </summary>
+        Task<ITextMessage> CreateTextMessageAsync();
+
+        /// <summary>
         /// Creates a new text message with the given body
         /// </summary>
         ITextMessage CreateTextMessage(string text);
 
         /// <summary>
+        /// Creates a new text message with the given body
+        /// </summary>
+        Task<ITextMessage> CreateTextMessageAsync(string text);
+
+        /// <summary>
         /// Creates a new Map message which contains primitive key and value pairs
         /// </summary>
         IMapMessage CreateMapMessage();
 
         /// <summary>
+        /// Creates a new Map message which contains primitive key and value pairs
+        /// </summary>
+        Task<IMapMessage> CreateMapMessageAsync();
+
+        /// <summary>
         /// Creates a new Object message containing the given .NET object as the body
         /// </summary>
         IObjectMessage CreateObjectMessage(object body);
 
         /// <summary>
+        /// Creates a new Object message containing the given .NET object as the body
+        /// </summary>
+        Task<IObjectMessage> CreateObjectMessageAsync(object body);
+
+        /// <summary>
         /// Creates a new binary message
         /// </summary>
         IBytesMessage CreateBytesMessage();
 
         /// <summary>
+        /// Creates a new binary message
+        /// </summary>
+        Task<IBytesMessage> CreateBytesMessageAsync();
+
+        /// <summary>
         /// Creates a new binary message with the given body
         /// </summary>
         IBytesMessage CreateBytesMessage(byte[] body);
 
         /// <summary>
+        /// Creates a new binary message with the given body
+        /// </summary>
+        Task<IBytesMessage> CreateBytesMessageAsync(byte[] body);
+
+        /// <summary>
         /// Creates a new stream message
         /// </summary>
         IStreamMessage CreateStreamMessage();
 
         /// <summary>
+        /// Creates a new stream message
+        /// </summary>
+        Task<IStreamMessage> CreateStreamMessageAsync();
+        
+        /// <summary>
         /// Closes the session.  There is no need to close the producers and consumers
         /// of a closed session.
         /// </summary>
         void Close();
+        
+        /// <summary>
+        /// Closes the session.  There is no need to close the producers and consumers
+        /// of a closed session.
+        /// </summary>
+        Task CloseAsync();
 
         /// <summary>
         /// A Delegate that is called each time a Message is dispatched to allow the client to do
diff --git a/src/nms-api/INMSProducer.cs b/src/nms-api/INMSProducer.cs
index c639f11..038bdb4 100644
--- a/src/nms-api/INMSProducer.cs
+++ b/src/nms-api/INMSProducer.cs
@@ -189,5 +189,10 @@ namespace Apache.NMS
         /// Close the producer.
         /// </summary>
         void Close();
+
+        /// <summary>
+        /// Close the producer.
+        /// </summary>
+        Task CloseAsync();
     }
 }
\ No newline at end of file
diff --git a/src/nms-api/INetTxConnection.cs b/src/nms-api/INetTxConnection.cs
index 56b56e3..0451f53 100644
--- a/src/nms-api/INetTxConnection.cs
+++ b/src/nms-api/INetTxConnection.cs
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+
+using System.Threading.Tasks;
 #if !NETCF
 using System.Transactions;
 
@@ -35,16 +37,30 @@ namespace Apache.NMS
         /// Creates a INetTxSession object.
         /// </summary>
         INetTxSession CreateNetTxSession();
+        
+        /// <summary>
+        /// Creates a INetTxSession object.
+        /// </summary>
+        Task<INetTxSession> CreateNetTxSessionAsync();
 
 #if !NETCF
         /// <summary>
         /// Creates a INetTxSession object and enlists in the specified Transaction.
         /// </summary>
         INetTxSession CreateNetTxSession(Transaction tx);
+        
+        /// <summary>
+        /// Creates a INetTxSession object and enlists in the specified Transaction.
+        /// </summary>
+        Task<INetTxSession> CreateNetTxSessionAsync(Transaction tx);
 
         INetTxSession CreateNetTxSession(bool enlistsNativeMsDtcResource);
+        
+        Task<INetTxSession> CreateNetTxSessionAsync(bool enlistsNativeMsDtcResource);
 
         INetTxSession CreateNetTxSession(Transaction tx, bool enlistsNativeMsDtcResource);
+        
+        Task<INetTxSession> CreateNetTxSessionAsync(Transaction tx, bool enlistsNativeMsDtcResource);
 #endif
     }
 }
\ No newline at end of file
diff --git a/src/nms-api/INetTxSession.cs b/src/nms-api/INetTxSession.cs
index e84072d..4f940f2 100644
--- a/src/nms-api/INetTxSession.cs
+++ b/src/nms-api/INetTxSession.cs
@@ -16,6 +16,7 @@
  */
 
 #if !NETCF
+using System.Threading.Tasks;
 using System.Transactions;
 
 #endif
@@ -50,6 +51,15 @@ namespace Apache.NMS
         /// be thrown.
         /// </summary>
         void Enlist(Transaction tx);
+        
+        /// <summary>
+        /// Enlist the Session in the specified Transaction.
+        /// 
+        /// If the Session is already enlisted in a Transaction or there is an Ambient
+        /// Transaction and the given TX is not that Transaction then an exception should
+        /// be thrown.
+        /// </summary>
+        Task EnlistAsync(Transaction tx);
 
         bool EnlistsMsDtcNativeResource { get; set; }
 #endif
diff --git a/src/nms-api/IQueueBrowser.cs b/src/nms-api/IQueueBrowser.cs
index 172c045..d2f71eb 100644
--- a/src/nms-api/IQueueBrowser.cs
+++ b/src/nms-api/IQueueBrowser.cs
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+using System.Threading.Tasks;
+
 namespace Apache.NMS
 {
     /// <summary>
@@ -37,6 +39,14 @@ namespace Apache.NMS
         /// If NMS Provider fails to close the Browser for some reason.
         /// </exception>
         void Close();
+        
+        /// <summary>
+        /// Closes the QueueBrowser.
+        /// </summary>
+        /// <exception cref="Apache.NMS.NMSException">
+        /// If NMS Provider fails to close the Browser for some reason.
+        /// </exception>
+        Task CloseAsync();
 
         /// <value>
         /// Gets this queue browser's message selector expression.  If no Message
diff --git a/src/nms-api/ISession.cs b/src/nms-api/ISession.cs
index cfd168f..59e29f8 100644
--- a/src/nms-api/ISession.cs
+++ b/src/nms-api/ISession.cs
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading.Tasks;
 
 namespace Apache.NMS
 {
@@ -35,6 +36,11 @@ namespace Apache.NMS
         /// Creates a producer of messages
         /// </summary>
         IMessageProducer CreateProducer();
+       
+        /// <summary>
+        /// Creates a producer of messages
+        /// </summary>
+        Task<IMessageProducer> CreateProducerAsync();
 
         /// <summary>
         /// Creates a producer of messages on a given destination
@@ -42,36 +48,73 @@ namespace Apache.NMS
         IMessageProducer CreateProducer(IDestination destination);
 
         /// <summary>
+        /// Creates a producer of messages on a given destination
+        /// </summary>
+        Task<IMessageProducer> CreateProducerAsync(IDestination destination);
+
+        /// <summary>
         /// Creates a consumer of messages on a given destination
         /// </summary>
         IMessageConsumer CreateConsumer(IDestination destination);
+        
+        /// <summary>
+        /// Creates a consumer of messages on a given destination
+        /// </summary>
+        Task<IMessageConsumer> CreateConsumerAsync(IDestination destination);
 
         /// <summary>
         /// Creates a consumer of messages on a given destination with a selector
         /// </summary>
         IMessageConsumer CreateConsumer(IDestination destination, string selector);
+        
+        /// <summary>
+        /// Creates a consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<IMessageConsumer> CreateConsumerAsync(IDestination destination, string selector);
 
         /// <summary>
         /// Creates a consumer of messages on a given destination with a selector
         /// </summary>
         IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal);
 
+        /// <summary>
+        /// Creates a consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<IMessageConsumer> CreateConsumerAsync(IDestination destination, string selector, bool noLocal);
+
         IMessageConsumer CreateDurableConsumer(ITopic destination, string name);
 
+        Task<IMessageConsumer> CreateDurableConsumerAsync(ITopic destination, string name);
+
         IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector);
+        
+        Task<IMessageConsumer> CreateDurableConsumerAsync(ITopic destination, string name, string selector);
 
         /// <summary>
         /// Creates a named durable consumer of messages on a given destination with a selector
         /// </summary>
         IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal);
+        
+        /// <summary>
+        /// Creates a named durable consumer of messages on a given destination with a selector
+        /// </summary>
+        Task<IMessageConsumer> CreateDurableConsumerAsync(ITopic destination, string name, string selector, bool noLocal);
 
         IMessageConsumer CreateSharedConsumer(ITopic destination, string name);
 
+        Task<IMessageConsumer> CreateSharedConsumerAsync(ITopic destination, string name);
+
         IMessageConsumer CreateSharedConsumer(ITopic destination, string name, string selector);
+        
+        Task<IMessageConsumer> CreateSharedConsumerAsync(ITopic destination, string name, string selector);
 
         IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name);
+        
+        Task<IMessageConsumer> CreateSharedDurableConsumerAsync(ITopic destination, string name);
 
         IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name, string selector);
+        
+        Task<IMessageConsumer> CreateSharedDurableConsumerAsync(ITopic destination, string name, string selector);
 
         /// <summary>
         /// Deletes a durable consumer created with CreateDurableConsumer().
@@ -82,6 +125,8 @@ namespace Apache.NMS
 
         void Unsubscribe(string name);
 
+        Task UnsubscribeAsync(string name);
+
         /// <summary>
         /// Creates a QueueBrowser object to peek at the messages on the specified queue.
         /// </summary>
@@ -97,6 +142,20 @@ namespace Apache.NMS
         IQueueBrowser CreateBrowser(IQueue queue);
 
         /// <summary>
+        /// Creates a QueueBrowser object to peek at the messages on the specified queue.
+        /// </summary>
+        /// <param name="queue">
+        /// A <see cref="IQueue"/>
+        /// </param>
+        /// <returns>
+        /// A <see cref="IQueueBrowser"/>
+        /// </returns>
+        /// <exception cref="System.NotSupportedException">
+        /// If the Prodiver does not support creation of Queue Browsers.
+        /// </exception>
+        Task<IQueueBrowser> CreateBrowserAsync(IQueue queue);
+
+        /// <summary>
         /// Creates a QueueBrowser object to peek at the messages on the specified queue
         /// using a message selector.
         /// </summary>
@@ -115,19 +174,52 @@ namespace Apache.NMS
         IQueueBrowser CreateBrowser(IQueue queue, string selector);
 
         /// <summary>
+        /// Creates a QueueBrowser object to peek at the messages on the specified queue
+        /// using a message selector.
+        /// </summary>
+        /// <param name="queue">
+        /// A <see cref="IQueue"/>
+        /// </param>
+        /// <param name="selector">
+        /// A <see cref="System.String"/>
+        /// </param>
+        /// <returns>
+        /// A <see cref="IQueueBrowser"/>
+        /// </returns>
+        /// <exception cref="System.NotSupportedException">
+        /// If the Prodiver does not support creation of Queue Browsers.
+        /// </exception>
+        Task<IQueueBrowser> CreateBrowserAsync(IQueue queue, string selector);
+
+        /// <summary>
         /// Returns the queue for the given name
         /// </summary>
         IQueue GetQueue(string name);
+        
+        /// <summary>
+        /// Returns the queue for the given name
+        /// </summary>
+        Task<IQueue> GetQueueAsync(string name);
 
         /// <summary>
         /// Returns the topic for the given name
         /// </summary>
         ITopic GetTopic(string name);
+        
+        /// <summary>
+        /// Returns the topic for the given name
+        /// </summary>
+        Task<ITopic> GetTopicAsync(string name);
 
         /// <summary>
         /// Creates a temporary queue
         /// </summary>
         ITemporaryQueue CreateTemporaryQueue();
+        
+        /// <summary>
+        /// Creates a temporary queue
+        /// </summary>
+        Task<ITemporaryQueue> CreateTemporaryQueueAsync();
 
         /// <summary>
         /// Creates a temporary topic
@@ -135,9 +227,19 @@ namespace Apache.NMS
         ITemporaryTopic CreateTemporaryTopic();
 
         /// <summary>
+        /// Creates a temporary topic
+        /// </summary>
+        Task<ITemporaryTopic> CreateTemporaryTopicAsync();
+
+        /// <summary>
         /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic).
         /// </summary>
         void DeleteDestination(IDestination destination);
+        
+        /// <summary>
+        /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic).
+        /// </summary>
+        Task DeleteDestinationAsync(IDestination destination);
 
         // Factory methods to create messages
 
@@ -147,45 +249,86 @@ namespace Apache.NMS
         IMessage CreateMessage();
 
         /// <summary>
+        /// Creates a new message with an empty body
+        /// </summary>
+        Task<IMessage> CreateMessageAsync();
+
+        /// <summary>
         /// Creates a new text message with an empty body
         /// </summary>
         ITextMessage CreateTextMessage();
 
         /// <summary>
+        /// Creates a new text message with an empty body
+        /// </summary>
+        Task<ITextMessage> CreateTextMessageAsync();
+
+        /// <summary>
         /// Creates a new text message with the given body
         /// </summary>
         ITextMessage CreateTextMessage(string text);
 
         /// <summary>
+        /// Creates a new text message with the given body
+        /// </summary>
+        Task<ITextMessage> CreateTextMessageAsync(string text);
+
+        /// <summary>
         /// Creates a new Map message which contains primitive key and value pairs
         /// </summary>
         IMapMessage CreateMapMessage();
 
         /// <summary>
+        /// Creates a new Map message which contains primitive key and value pairs
+        /// </summary>
+        Task<IMapMessage> CreateMapMessageAsync();
+
+        /// <summary>
         /// Creates a new Object message containing the given .NET object as the body
         /// </summary>
         IObjectMessage CreateObjectMessage(object body);
 
         /// <summary>
+        /// Creates a new Object message containing the given .NET object as the body
+        /// </summary>
+        Task<IObjectMessage> CreateObjectMessageAsync(object body);
+
+        /// <summary>
         /// Creates a new binary message
         /// </summary>
         IBytesMessage CreateBytesMessage();
 
         /// <summary>
+        /// Creates a new binary message
+        /// </summary>
+        Task<IBytesMessage> CreateBytesMessageAsync();
+
+        /// <summary>
         /// Creates a new binary message with the given body
         /// </summary>
         IBytesMessage CreateBytesMessage(byte[] body);
 
         /// <summary>
+        /// Creates a new binary message with the given body
+        /// </summary>
+        Task<IBytesMessage> CreateBytesMessageAsync(byte[] body);
+
+        /// <summary>
         /// Creates a new stream message
         /// </summary>
         IStreamMessage CreateStreamMessage();
 
         /// <summary>
+        /// Creates a new stream message
+        /// </summary>
+        Task<IStreamMessage> CreateStreamMessageAsync();
+
+        /// <summary>
         /// Closes the session.  There is no need to close the producers and consumers
         /// of a closed session.
         /// </summary>
         void Close();
+        Task CloseAsync();
 
         /// <summary>
         /// A Delegate that is called each time a Message is dispatched to allow the client to do
@@ -223,10 +366,22 @@ namespace Apache.NMS
         void Commit();
 
         /// <summary>
+        /// If this is a transactional session then commit all message
+        /// send and acknowledgements for producers and consumers in this session
+        /// </summary>
+        Task CommitAsync();
+
+        /// <summary>
         /// If this is a transactional session then rollback all message
         /// send and acknowledgements for producers and consumers in this session
         /// </summary>
         void Rollback();
+        
+        /// <summary>
+        /// If this is a transactional session then rollback all message
+        /// send and acknowledgements for producers and consumers in this session
+        /// </summary>
+        Task RollbackAsync();
 
         #endregion
 
diff --git a/src/nms-api/IStartable.cs b/src/nms-api/IStartable.cs
index 5e388b4..82ca693 100644
--- a/src/nms-api/IStartable.cs
+++ b/src/nms-api/IStartable.cs
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+using System.Threading.Tasks;
+
 namespace Apache.NMS
 {
     /// <summary>
@@ -23,6 +25,9 @@ namespace Apache.NMS
     public interface IStartable
     {
         void Start();
+
+        Task StartAsync();
+        
         bool IsStarted { get; }
     }
 }
\ No newline at end of file
diff --git a/src/nms-api/IStoppable.cs b/src/nms-api/IStoppable.cs
index ad88977..b52f657 100644
--- a/src/nms-api/IStoppable.cs
+++ b/src/nms-api/IStoppable.cs
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+using System.Threading.Tasks;
+
 namespace Apache.NMS
 {
     /// <summary>
@@ -23,5 +25,7 @@ namespace Apache.NMS
     public interface IStoppable
     {
         void Stop();
+
+        Task StopAsync();
     }
 }
\ No newline at end of file
diff --git a/src/nms-api/NMSConnectionFactory.cs b/src/nms-api/NMSConnectionFactory.cs
index 8ccdb56..9e14ed3 100644
--- a/src/nms-api/NMSConnectionFactory.cs
+++ b/src/nms-api/NMSConnectionFactory.cs
@@ -20,6 +20,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using System.Reflection;
+using System.Threading.Tasks;
 using System.Xml;
 using Apache.NMS.Util;
 
@@ -404,6 +405,16 @@ namespace Apache.NMS
             return this.factory.CreateConnection(userName, password);
         }
 
+        public Task<IConnection> CreateConnectionAsync()
+        {
+            return this.factory.CreateConnectionAsync();
+        }
+
+        public Task<IConnection> CreateConnectionAsync(string userName, string password)
+        {
+            return this.factory.CreateConnectionAsync(userName, password);
+        }
+
         public INMSContext CreateContext()
         {
             return this.factory.CreateContext();
@@ -424,6 +435,26 @@ namespace Apache.NMS
             return this.factory.CreateContext(userName, password, acknowledgementMode);
         }
 
+        public Task<INMSContext> CreateContextAsync()
+        {
+            return this.factory.CreateContextAsync();
+        }
+
+        public Task<INMSContext> CreateContextAsync(AcknowledgementMode acknowledgementMode)
+        {
+            return this.factory.CreateContextAsync(acknowledgementMode);
+        }
+
+        public Task<INMSContext> CreateContextAsync(string userName, string password)
+        {
+            return this.factory.CreateContextAsync(userName, password);
+        }
+
+        public Task<INMSContext> CreateContextAsync(string userName, string password, AcknowledgementMode acknowledgementMode)
+        {
+            return this.factory.CreateContextAsync(userName, password, acknowledgementMode);
+        }
+
         /// <summary>
         /// Get/or set the broker Uri.
         /// </summary>