Skip to content
Permalink
Browse files
AMQNET-637 NMS 2.0
Add deliverydelay
Add async send methods
Add shared and shared durable consumers
add missing ack method on session thats in JMS
Create INMSConsumer
Create INMSProducer
Create INMSContext
Add Create Context Methods to ConnectionFactory
Add CreateContext wrapper methods in factory
fix missing file type
remove duplicate method signature
Remove duplicated method
remove unspec'd methods
changes to address review comments from Krystof.
  • Loading branch information
michaelandrepearce committed Apr 5, 2020
1 parent 27a263c commit 88e7550cc68dd1941141da1baa6c86b31be68d93
Show file tree
Hide file tree
Showing 9 changed files with 1,064 additions and 452 deletions.
@@ -33,6 +33,27 @@ public interface IConnectionFactory
/// Creates a new connection with the given user name and password
/// </summary>
IConnection CreateConnection(string userName, string password);

/// <summary>
/// Creates a new context
/// </summary>
INMSContext CreateContext();

/// <summary>
/// Creates a new context with the given acknowledgement mode.
/// </summary>
INMSContext CreateContext(AcknowledgementMode acknowledgementMode);

/// <summary>
/// Creates a new context with the given user name and password
/// </summary>
INMSContext CreateContext(string userName, string password);

/// <summary>
/// Creates a new context with the given user name, password and acknowledgement mode
/// </summary>
INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode);


/// <summary>
/// Get/or set the broker Uri.
@@ -100,5 +100,18 @@ public interface IMessage
/// The type name of this message.
/// </summary>
string NMSType { get; set; }

/// <summary>
/// When a message is sent, the NMSDeliveryTime header field is
/// left unassigned. After completion of the send or
/// publish method, it holds the delivery time of the message.
/// This is the the difference, measured in milliseconds,
/// between the delivery time and midnight, January 1, 1970 UTC.
///
/// A message's delivery time is the earliest time when a JMS provider may
/// deliver the message to a consumer. The provider must not deliver messages
/// before the delivery time has been reached.
/// <summary>
DateTime NMSDeliveryTime { get; set; }
}
}
@@ -15,9 +15,13 @@
* limitations under the License.
*/
using System;
using System.Threading.Tasks;

namespace Apache.NMS
{
public delegate void CompletionListener(IMessage message, Exception e);


/// <summary>
/// A delegate that a client can register that will be called each time a Producer's send method is
/// called to allow the client to Transform a sent message from one type to another, StreamMessage to
@@ -54,6 +58,47 @@ public interface IMessageProducer : System.IDisposable
/// </summary>
void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);

/// <summary>
/// Sends the message to the default destination for this producer
/// </summary>
void Send(IMessage message, CompletionListener completionListener);

/// <summary>
/// Sends the message to the default destination with the explicit QoS configuration
/// </summary>
void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, CompletionListener completionListener);

/// <summary>
/// Sends the message to the given destination
/// </summary>
void Send(IDestination destination, IMessage message, CompletionListener completionListener);

/// <summary>
/// Sends the message to the given destination with the explicit QoS configuration
/// </summary>
void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, CompletionListener completionListener);

/// <summary>
/// Sends the message to the default destination for this producer
/// </summary>
Task SendAsync(IMessage message);

/// <summary>
/// Sends the message to the default destination with the explicit QoS configuration
/// </summary>
Task SendAsync(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);

/// <summary>
/// Sends the message to the given destination
/// </summary>
Task SendAsync(IDestination destination, IMessage message);

/// <summary>
/// Sends the message to the given destination with the explicit QoS configuration
/// </summary>
Task SendAsync(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);


/// <summary>
/// Close the producer.
/// </summary>
@@ -76,6 +121,8 @@ public interface IMessageProducer : System.IDisposable
bool DisableMessageID { get; set; }

bool DisableMessageTimestamp { get; set; }

TimeSpan DeliveryDelay { get; set; }

#region Factory methods to create messages

@@ -0,0 +1,77 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
using System;

namespace Apache.NMS
{

/// <summary>
/// An object capable of sending messages to some destination
/// </summary>
public interface INMSConsumer : System.IDisposable
{

string MessageSelector { get; }

/// <summary>
/// Waits until a message is available and returns it
/// </summary>
IMessage Receive();

/// <summary>
/// If a message is available within the timeout duration it is returned otherwise this method returns null
/// </summary>
IMessage Receive(TimeSpan timeout);

/// <summary>
/// Receives the next message if one is immediately available for delivery on the client side
/// otherwise this method returns null. It is never an error for this method to return null, the
/// time of Message availability varies so your client cannot rely on this method to receive a
/// message immediately after one has been sent.
/// </summary>
IMessage ReceiveNoWait();


T ReceiveBody<T>();

T ReceiveBody<T>(TimeSpan timeout);

T ReceiveBodyNoWait<T>();


/// <summary>
/// An asynchronous listener which can be used to consume messages asynchronously
/// </summary>
event MessageListener Listener;

/// <summary>
/// Closes the message consumer.
/// </summary>
/// <remarks>
/// Clients should close message consumers when they are not needed.
/// This call blocks until a receive or message listener in progress has completed.
/// A blocked message consumer receive call returns null when this message consumer is closed.
/// </remarks>
void Close();

/// <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>
ConsumerTransformerDelegate ConsumerTransformer { get; set; }
}
}

0 comments on commit 88e7550

Please sign in to comment.