Skip to content
Permalink
Browse files
AMQNET-637 NMS 2.0 More async methods
  • Loading branch information
lukeabsent committed Feb 5, 2021
1 parent 3e3cc54 commit d045738829aaf8dda169b8cb0afacbe2c856307a
Showing 14 changed files with 472 additions and 5 deletions.
@@ -16,6 +16,7 @@
*/

using System;
using System.Threading.Tasks;

namespace Apache.NMS
{
@@ -100,10 +101,25 @@ public interface IConnection : IDisposable, IStartable, IStoppable
/// </summary>
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
@@ -16,6 +16,7 @@
*/

using System;
using System.Threading.Tasks;

namespace Apache.NMS
{
@@ -32,8 +33,18 @@ public interface IConnectionFactory
/// <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>
@@ -53,7 +64,26 @@ public interface IConnectionFactory
/// 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.
@@ -15,6 +15,8 @@
* limitations under the License.
*/

using System.Threading.Tasks;

namespace Apache.NMS
{
/// <summary>
@@ -42,11 +44,21 @@ public interface IMessageConsumer : System.IDisposable
/// 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 @@ public interface IMessageConsumer : System.IDisposable
/// 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
@@ -85,6 +85,11 @@ public interface IMessageProducer : System.IDisposable
/// </summary>
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.
@@ -16,6 +16,7 @@
*/

using System;
using System.Threading.Tasks;

namespace Apache.NMS
{
@@ -29,11 +30,21 @@ public interface INMSConsumer : System.IDisposable
/// 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 @@ public interface INMSConsumer : System.IDisposable


T ReceiveBody<T>();

Task<T> ReceiveBodyAsync<T>();

T ReceiveBody<T>(TimeSpan timeout);

Task<T> ReceiveBodyAsync<T>(TimeSpan timeout);

T ReceiveBodyNoWait<T>();

@@ -67,6 +82,14 @@ public interface INMSConsumer : System.IDisposable
/// </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
/// any necessary transformations on the received message before it is delivered.

0 comments on commit d045738

Please sign in to comment.