/* * * 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.Qpid.Messaging { public delegate void MessageReceivedDelegate(IMessage msg); /// /// IChannel provides methods to access the commands in AMQP that operate at the channel level. This can be summarized as /// the ability to declare queues and exchanges, bind queues to exchanges, create messages of various types, declare transaction /// boundaries (commit and rollback), and to set up producers and consumers on the channel. /// ///

You can create a channel by using the CreateChannel() method /// of the connection object. /// ///

///
CRC Card
Responsibilities ///
Declare queues. ///
Declare exchanges. ///
Bind queues to exchanges. ///
Create messages. ///
Set up message consumers on the channel. ///
Set up message producers on the channel. ///
Commit the current transaction. ///
Roll-back the current transaction. ///
Close the channel. ///
///

public interface IChannel : IDisposable, ICloseable { /// /// Acknowledge mode for messages received. /// AcknowledgeMode AcknowledgeMode { get; } /// /// True if the channel should use transactions. /// bool Transacted { get; } /// /// Prefetch value to be used as the default for /// consumers created on this channel. /// int DefaultPrefetch { get; } /// /// Prefetch low value to be used as the default for /// consumers created on this channel. /// int DefaultPrefetchLow { get; } /// /// Prefetch high value to be used as the default for /// consumers created on this channel. /// int DefaultPrefetchHigh { get; } /// /// Declare a new exchange. /// /// Name of the exchange /// Class of the exchange, from void DeclareExchange(string exchangeName, string exchangeClass); /// /// Declare a new exchange using the default exchange class. /// /// Name of the exchange void DeleteExchange(string exchangeName); /// /// Declare a new queue with the specified set of arguments. /// /// Name of the queue /// True if the queue should be durable /// True if the queue should be exclusive to this channel /// True if the queue should be deleted when the channel closes void DeclareQueue(string queueName, bool isDurable, bool isExclusive, bool isAutoDelete); /// /// Declare a new queue with the specified set of arguments. /// /// Name of the queue /// True if the queue should be durable /// True if the queue should be exclusive to this channel /// True if the queue should be deleted when the channel closes /// Optional arguments to Queue.Declare void DeclareQueue(string queueName, bool isDurable, bool isExclusive, bool isAutoDelete, IFieldTable args); /// /// Delete a queue with the specifies arguments. /// /// Name of the queue to delete /// If true, the queue will not deleted if it has no consumers /// If true, the queue will not deleted if it has no messages /// If true, the server will not respond to the method void DeleteQueue(string queueName, bool ifUnused, bool ifEmpty, bool noWait); /// /// Generate a new Unique name to use for a queue. /// /// A unique name to this channel string GenerateUniqueName(); /// /// Removes all messages from a queue. /// /// Name of the queue to delete /// If true, the server will not respond to the method void PurgeQueue(string queueName, bool noWait); /// /// Bind a queue to the specified exchange. /// /// Name of queue to bind /// Name of exchange to bind to /// Routing key void Bind(string queueName, string exchangeName, string routingKey); /// /// Bind a queue to the specified exchange. /// /// Name of queue to bind /// Name of exchange to bind to /// Routing key /// Table of arguments for the binding. Used to bind with a Headers Exchange void Bind(string queueName, string exchangeName, string routingKey, IFieldTable args); /// /// Create a new empty message with no body. /// /// The new message IMessage CreateMessage(); /// /// Create a new message of the specified MIME type. /// /// The mime type to create /// The new message IMessage CreateMessage(string mimeType); /// /// Creates a new message for bytes (application/octet-stream). /// /// The new message IBytesMessage CreateBytesMessage(); /// /// Creates a new text message (text/plain) with empty content. /// /// The new message ITextMessage CreateTextMessage(); /// /// Creates a new text message (text/plain) with a body. /// /// Initial body of the message /// The new message ITextMessage CreateTextMessage(string initialValue); #region Consuming /// /// Creates a new Consumer using the builder pattern. /// /// Name of queue to receive messages from /// The builder object MessageConsumerBuilder CreateConsumerBuilder(string queueName); /// /// Creates a new consumer. /// /// Name of queue to receive messages from /// Low prefetch value /// High prefetch value /// If true, messages sent on this channel will not be received by this consumer /// If true, the consumer opens the queue in exclusive mode /// The new consumer IMessageConsumer CreateConsumer(string queueName, int prefetchLow, int prefetchHigh, bool noLocal, bool exclusive); /// /// Creates a new consumer. /// /// Name of queue to receive messages from /// Low prefetch value /// High prefetch value /// If true, messages sent on this channel will not be received by this consumer /// If true, the consumer opens the queue in exclusive mode /// If true, the consumer only browses and does not consume /// The new consumer IMessageConsumer CreateConsumer(string queueName, int prefetchLow, int prefetchHigh, bool noLocal, bool exclusive, bool browse); /// /// Unsubscribe from a queue. /// /// Subscription name void Unsubscribe(string subscriptionName); #endregion #region Publishing /// /// Create a new message publisher using the builder pattern. /// /// The builder object MessagePublisherBuilder CreatePublisherBuilder(); /// /// Create a new message publisher. /// /// Name of exchange to publish to /// Routing key /// Default delivery mode /// Default TTL time of messages /// If true, sent immediately /// If true, the broker will return an error /// (as a connection exception) if the message cannot be delivered /// Default message priority /// The new message publisher IMessagePublisher CreatePublisher(string exchangeName, string routingKey, DeliveryMode deliveryMode, long timeToLive, bool immediate, bool mandatory, int priority); #endregion #region Transactions /// /// Recover after transaction failure. /// void Recover(); /// /// Commit the transaction. /// void Commit(); /// /// Rollback the transaction. /// void Rollback(); #endregion } }