/* * 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 { /// /// The mode used to acknowledge messages after they are consumed /// public enum AcknowledgementMode { /// /// 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. /// AutoAcknowledge, /// /// 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. /// DupsOkAcknowledge, /// /// 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. /// ClientAcknowledge, /// /// Messages will be consumed when the transaction commits. /// Transactional, /// /// 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. /// IndividualAcknowledge } /// /// A delegate that can receive transport level exceptions. /// public delegate void ExceptionListener(Exception exception); /// /// 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. /// public delegate void ConnectionInterruptedListener(); /// /// A delegate that is used by Fault tolerant NMS Implementation to notify their /// clients that the Connection that was interrupted has now been restored. /// public delegate void ConnectionResumedListener(); /// /// Represents a connection with a message broker /// public interface IConnection : IDisposable, IStartable, IStoppable { /// /// Creates a new session to work on this connection /// ISession CreateSession(); /// /// Creates a new session to work on this connection /// ISession CreateSession(AcknowledgementMode acknowledgementMode); /// /// Closes the connection. /// void Close(); /// /// An asynchronous listener which can be notified if an error occurs /// event ExceptionListener ExceptionListener; /// /// An asynchronous listener that is notified when a Fault tolerant connection /// has been interrupted. /// event ConnectionInterruptedListener ConnectionInterruptedListener; /// /// An asynchronous listener that is notified when a Fault tolerant connection /// has been resumed. /// event ConnectionResumedListener ConnectionResumedListener; /// /// 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. /// ConsumerTransformerDelegate ConsumerTransformer { get; set; } /// /// 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. /// ProducerTransformerDelegate ProducerTransformer { get; set; } #region Attributes /// /// The default timeout for network requests. /// TimeSpan RequestTimeout { get; set; } /// /// The default acknowledgement mode /// AcknowledgementMode AcknowledgementMode { get; set; } /// /// Sets the unique clienet ID for this connection before Start() or returns the /// unique client ID after the connection has started /// string ClientId { get; set; } /// /// Get/or set the redelivery policy for this connection. /// IRedeliveryPolicy RedeliveryPolicy { get; set; } /// /// Gets the Meta Data for the NMS Connection instance. /// IConnectionMetaData MetaData{ get; } #endregion } }