/*
*
* 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
{
///
/// Describes an object that can be used to receive (consume)
/// messages from an AMQP queue.
///
///
/// Consumers are created using either
/// or using
/// the builder pattern (preferred) with
/// .
///
///
/// Consumers offer two different ways of receiving messages:
/// You can attach a delegate to the
/// event and be notified when a message arrives, or you can
/// use the and
/// methods to control when you receive messages. Be aware that you can use
/// one or the other, but not both at the same time.
///
///
/// Regardless of which method you choose, the prefetch settings
/// specified when creating the channel will still control when messages
/// are actually received from the AMQP broker. Any messages that arrive
/// between the prefetch window will be queued by the channel
/// until they can be delivered to the consumer (either though the event
/// or until the consumer actively calls ).
///
///
public interface IMessageConsumer : IDisposable
{
///
/// Fired when a message is received from the broker by the consumer
///
MessageReceivedDelegate OnMessage { get; set; }
///
/// Wait infinitely for a message to be received from the broker
///
/// The message received
IMessage Receive();
///
/// Wait the specified time until a message is receive from the broker
///
/// Maximum number of milliseconds to wait for a message
/// The message received, or null if the timeout expires
IMessage Receive(long delay);
///
/// Return a message if one is already available in the channel.
/// Does not wait for one to be received from the broker.
///
/// The message, if it was available, otherwise null
IMessage ReceiveNoWait();
}
}