Skip to content
Permalink
Browse files
Implement enhancements for EMS provider.
  • Loading branch information
Jim Gomes committed Aug 30, 2010
1 parent 9ff7f10 commit 92d420824d46258bfb82975bbe51d31f8013999d
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 277 deletions.
@@ -18,161 +18,153 @@

namespace Apache.NMS
{
/// <summary>
/// The mode used to acknowledge messages after they are consumed
/// </summary>
public enum AcknowledgementMode
{
/// <summary>
/// With this acknowledgment mode, the session will not
/// acknowledge receipt of a message since the broker assumes
/// successful receipt of a message after the onMessage handler
/// has returned without error.
/// </summary>
AutoAcknowledge,

/// <summary>
/// With this acknowledgment mode, the session automatically
/// acknowledges a client's receipt of a message either when
/// the session has successfully returned from a call to receive
/// or when the message listener the session has called to
/// process the message successfully returns. Acknowlegements
/// may be delayed in this mode to increase performance at
/// the cost of the message being redelivered this client fails.
/// </summary>
DupsOkAcknowledge,

/// <summary>
/// With this acknowledgment mode, the client acknowledges a
/// consumed message by calling the message's acknowledge method.
/// This acknowledgement acknowledges the given message and all
/// unacknowedged messages that have preceeded it for the session
/// in which the message was delivered.
/// </summary>
ClientAcknowledge,

/// <summary>
/// Messages will be consumed when the transaction commits.
/// </summary>
Transactional,

/// <summary>
/// With this acknowledgment mode, the client acknowledges a
/// consumed message by calling the message's acknowledge method.
/// This acknowledgement mode allows the client to acknowledge a
/// single message. This mode is not required to be supported by
/// all NMS providers, however the provider should throw an appropriate
/// exception to indicate that the mode is unsupported.
/// </summary>
IndividualAcknowledge
}

/// <summary>
/// A delegate that can receive transport level exceptions.
/// </summary>
public delegate void ExceptionListener(Exception exception);

/// <summary>
/// A delegate that is used by Fault tolerant NMS Implementation to notify their
/// clients that the Connection is not currently active to due some error.
/// </summary>
public delegate void ConnectionInterruptedListener();

/// <summary>
/// A delegate that is used by Fault tolerant NMS Implementation to notify their
/// clients that the Connection that was interrupted has now been restored.
/// </summary>
public delegate void ConnectionResumedListener();

/// <summary>
/// Represents a connection with a message broker
/// </summary>
public interface IConnection : IDisposable, IStartable, IStoppable
{
/// <summary>
/// Creates a new session to work on this connection
/// </summary>
ISession CreateSession();

/// <summary>
/// Creates a new session to work on this connection
/// </summary>
ISession CreateSession(AcknowledgementMode acknowledgementMode);

/// <summary>
/// Closes the connection.
/// </summary>
void Close();

/// <summary>
/// An asynchronous listener which can be notified if an error occurs
/// </summary>
event ExceptionListener ExceptionListener;

/// <summary>
/// An asynchronous listener that is notified when a Fault tolerant connection
/// has been interrupted.
/// </summary>
event ConnectionInterruptedListener ConnectionInterruptedListener;

/// <summary>
/// An asynchronous listener that is notified when a Fault tolerant connection
/// has been resumed.
/// </summary>
event ConnectionResumedListener ConnectionResumedListener;

/// <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. The
/// Connection sets the provided delegate instance on each Session it creates which then
/// passes that along to the Consumers it creates.
/// </summary>
ConsumerTransformerDelegate ConsumerTransformer
{
get;
set;
}

/// <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.
/// The Connection sets the provided delegate instance on each Session it creates which then
/// passes that along to the Producer it creates.
/// </summary>
ProducerTransformerDelegate ProducerTransformer
{
get;
set;
}

#region Attributes

/// <summary>
/// The default timeout for network requests.
/// </summary>
TimeSpan RequestTimeout { get; set; }

/// <summary>
/// The default acknowledgement mode
/// </summary>
AcknowledgementMode AcknowledgementMode { get; set; }

/// <summary>
/// Sets the unique clienet ID for this connection before Start() or returns the
/// unique client ID after the connection has started
/// </summary>
string ClientId { get; set; }
/// <summary>
/// The mode used to acknowledge messages after they are consumed
/// </summary>
public enum AcknowledgementMode
{
/// <summary>
/// With this acknowledgment mode, the session will not
/// acknowledge receipt of a message since the broker assumes
/// successful receipt of a message after the onMessage handler
/// has returned without error.
/// </summary>
AutoAcknowledge,

/// <summary>
/// With this acknowledgment mode, the session automatically
/// acknowledges a client's receipt of a message either when
/// the session has successfully returned from a call to receive
/// or when the message listener the session has called to
/// process the message successfully returns. Acknowlegements
/// may be delayed in this mode to increase performance at
/// the cost of the message being redelivered this client fails.
/// </summary>
DupsOkAcknowledge,

/// <summary>
/// With this acknowledgment mode, the client acknowledges a
/// consumed message by calling the message's acknowledge method.
/// This acknowledgement acknowledges the given message and all
/// unacknowedged messages that have preceeded it for the session
/// in which the message was delivered.
/// </summary>
ClientAcknowledge,

/// <summary>
/// Messages will be consumed when the transaction commits.
/// </summary>
Transactional,

/// <summary>
/// With this acknowledgment mode, the client acknowledges a
/// consumed message by calling the message's acknowledge method.
/// This acknowledgement mode allows the client to acknowledge a
/// single message. This mode is not required to be supported by
/// all NMS providers, however the provider should throw an appropriate
/// exception to indicate that the mode is unsupported.
/// </summary>
IndividualAcknowledge
}

/// <summary>
/// A delegate that can receive transport level exceptions.
/// </summary>
public delegate void ExceptionListener(Exception exception);

/// <summary>
/// A delegate that is used by Fault tolerant NMS Implementation to notify their
/// clients that the Connection is not currently active to due some error.
/// </summary>
public delegate void ConnectionInterruptedListener();

/// <summary>
/// A delegate that is used by Fault tolerant NMS Implementation to notify their
/// clients that the Connection that was interrupted has now been restored.
/// </summary>
public delegate void ConnectionResumedListener();

/// <summary>
/// Represents a connection with a message broker
/// </summary>
public interface IConnection : IDisposable, IStartable, IStoppable
{
/// <summary>
/// Creates a new session to work on this connection
/// </summary>
ISession CreateSession();

/// <summary>
/// Creates a new session to work on this connection
/// </summary>
ISession CreateSession(AcknowledgementMode acknowledgementMode);

/// <summary>
/// Closes the connection.
/// </summary>
void Close();

/// <summary>
/// An asynchronous listener which can be notified if an error occurs
/// </summary>
event ExceptionListener ExceptionListener;

/// <summary>
/// An asynchronous listener that is notified when a Fault tolerant connection
/// has been interrupted.
/// </summary>
event ConnectionInterruptedListener ConnectionInterruptedListener;

/// <summary>
/// An asynchronous listener that is notified when a Fault tolerant connection
/// has been resumed.
/// </summary>
event ConnectionResumedListener ConnectionResumedListener;

/// <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. The
/// Connection sets the provided delegate instance on each Session it creates which then
/// passes that along to the Consumers it creates.
/// </summary>
ConsumerTransformerDelegate ConsumerTransformer { get; set; }

/// <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.
/// The Connection sets the provided delegate instance on each Session it creates which then
/// passes that along to the Producer it creates.
/// </summary>
ProducerTransformerDelegate ProducerTransformer { get; set; }

#region Attributes

/// <summary>
/// The default timeout for network requests.
/// </summary>
TimeSpan RequestTimeout { get; set; }

/// <summary>
/// The default acknowledgement mode
/// </summary>
AcknowledgementMode AcknowledgementMode { get; set; }

/// <summary>
/// Sets the unique clienet ID for this connection before Start() or returns the
/// unique client ID after the connection has started
/// </summary>
string ClientId { get; set; }

/// <summary>
/// Get/or set the redelivery policy for this connection.
/// </summary>
IRedeliveryPolicy RedeliveryPolicy { get; set; }

/// <summary>
/// Gets the Meta Data for the NMS Connection instance.
/// </summary>
IConnectionMetaData MetaData{ get; }
/// Gets the Meta Data for the NMS Connection instance.
/// </summary>
IConnectionMetaData MetaData{ get; }

#endregion
}
#endregion
}
}
@@ -28,7 +28,7 @@ public interface IConnectionFactory
/// Creates a new connection
/// </summary>
IConnection CreateConnection();

/// <summary>
/// Creates a new connection with the given user name and password
/// </summary>
@@ -39,36 +39,28 @@ public interface IConnectionFactory
/// </summary>
Uri BrokerUri { get; set; }

/// <summary>
/// Get/or set the redelivery policy that new IConnection objects are
/// assigned upon creation.
/// </summary>
IRedeliveryPolicy RedeliveryPolicy{ get; set; }
/// <summary>
/// Get/or set the redelivery policy that new IConnection objects are
/// assigned upon creation.
/// </summary>
IRedeliveryPolicy RedeliveryPolicy { get; set; }

/// <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. The
/// ConnectionFactory sets the provided delegate instance on each Connection instance that
/// is created from this factory, each connection in turn passes the delegate along to each
/// Session it creates which then passes that along to the Consumers it creates.
/// </summary>
ConsumerTransformerDelegate ConsumerTransformer
{
get;
set;
}
/// <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. The
/// ConnectionFactory sets the provided delegate instance on each Connection instance that
/// is created from this factory, each connection in turn passes the delegate along to each
/// Session it creates which then passes that along to the Consumers it creates.
/// </summary>
ConsumerTransformerDelegate ConsumerTransformer { get; set; }

/// <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.
/// The ConnectionFactory sets the provided delegate instance on each Connection instance that
/// is created from this factory, each connection in turn passes the delegate along to each
/// Session it creates which then passes that along to the Producers it creates.
/// </summary>
ProducerTransformerDelegate ProducerTransformer
{
get;
set;
}
/// <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.
/// The ConnectionFactory sets the provided delegate instance on each Connection instance that
/// is created from this factory, each connection in turn passes the delegate along to each
/// Session it creates which then passes that along to the Producers it creates.
/// </summary>
ProducerTransformerDelegate ProducerTransformer { get; set; }
}
}

0 comments on commit 92d4208

Please sign in to comment.