Hade du nytta av den här sidan?
Din feedback om det här innehållet är viktig. Berätta vad du tycker.
Ytterligare feedback?
1500 tecken kvar
MessageReceiver Class
Collapse the table of content
Expand the table of content
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

MessageReceiver Class

 

Receives messages from the message container and acknowledges them.

Namespace:   Microsoft.ServiceBus.Messaging
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)


public abstract class MessageReceiver : MessageClientEntity

NameDescription
System_CAPS_pubpropertyBatchFlushInterval

Gets the batch flush interval.

System_CAPS_protpropertyBatchingEnabled

Gets a value indicating whether the batching is enabled.

System_CAPS_pubpropertyIsClosed

(Inherited from ClientEntity.)

System_CAPS_pubpropertyLastPeekedSequenceNumber

Gets or sets the sequence number of the message last peeked.

System_CAPS_pubpropertyMode

Gets the message receive mode.

System_CAPS_protpropertyOffsetInclusive

System_CAPS_pubpropertyPath

Gets the path of the queue or topic, relative to the MessagingFactory base address.

System_CAPS_pubpropertyPrefetchCount

Gets or sets the number of messages that the message receiver can simultaneously request.

System_CAPS_protpropertyReceiverStartTime

Gets or sets the start time of the receiver.

System_CAPS_pubpropertyRetryPolicy

(Inherited from ClientEntity.)

System_CAPS_protpropertyStartOffset

Gets or sets the starting point of the offset.

System_CAPS_protpropertySupportsGetRuntimeEntityDescription

System_CAPS_protpropertyThisLock

(Inherited from ClientEntity.)

NameDescription
System_CAPS_pubmethodAbandon(Guid)

Discards the message and relinquishes the message lock ownership.

System_CAPS_pubmethodAbandon(Guid, IDictionary<String, Object>)

Discards the message and relinquishes the message lock ownership.

System_CAPS_pubmethodAbandonAsync(Guid)

Asynchronously discards the message and relinquishes the message lock ownership.

System_CAPS_pubmethodAbandonAsync(Guid, IDictionary<String, Object>)

Asynchronously discards the message and relinquishes the message lock ownership.

System_CAPS_pubmethodAbort()

Performs abort functionality on the messaging entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodBeginAbandon(Guid, AsyncCallback, Object)

Begins an asynchronous operation to abandon the message and relinquish its lock.

System_CAPS_pubmethodBeginAbandon(Guid, IDictionary<String, Object>, AsyncCallback, Object)

Begins an asynchronous operation to abandon the message and relinquish its lock.

System_CAPS_pubmethodBeginClose(AsyncCallback, Object)

Begins an asynchronous operation to close the message client entity.(Inherited from MessageClientEntity.)

System_CAPS_pubmethodBeginComplete(Guid, AsyncCallback, Object)

Begins an asynchronous operation to complete receipt of a message.

System_CAPS_pubmethodBeginCompleteBatch(IEnumerable<Guid>, AsyncCallback, Object)

Begins an asynchronous operation to complete a message batching.

System_CAPS_pubmethodBeginDeadLetter(Guid, AsyncCallback, Object)

Begins an asynchronous operation to move a message to the dead letter queue.

System_CAPS_pubmethodBeginDeadLetter(Guid, IDictionary<String, Object>, AsyncCallback, Object)

Begins an asynchronous operation to move a message to the dead letter queue.

System_CAPS_pubmethodBeginDeadLetter(Guid, String, String, AsyncCallback, Object)

Begins an asynchronous operation to move a message to the dead letter queue.

System_CAPS_pubmethodBeginDefer(Guid, AsyncCallback, Object)

Begins an asynchronous operation to suspend receipt of a message.

System_CAPS_pubmethodBeginDefer(Guid, IDictionary<String, Object>, AsyncCallback, Object)

Begins an asynchronous operation to suspend receipt of a message.

System_CAPS_pubmethodBeginPeek(AsyncCallback, Object)

Begins an operation to peek a message.

System_CAPS_pubmethodBeginPeek(Int64, AsyncCallback, Object)

Begins an operation to peek a message.

System_CAPS_pubmethodBeginPeekBatch(Int32, AsyncCallback, Object)

Begins an operation to peek a batch of message.

System_CAPS_pubmethodBeginPeekBatch(Int64, Int32, AsyncCallback, Object)

Begins an operation to peek a batch of message.

System_CAPS_pubmethodBeginReceive(AsyncCallback, Object)

Begins an asynchronous operation to receive a message.

System_CAPS_pubmethodBeginReceive(Int64, AsyncCallback, Object)

Begins an asynchronous operation to receive a message.

System_CAPS_pubmethodBeginReceive(TimeSpan, AsyncCallback, Object)

Begins an asynchronous operation to receive a message.

System_CAPS_pubmethodBeginReceiveBatch(IEnumerable<Int64>, AsyncCallback, Object)

Begins an asynchronous operation to receive a batch of message.

System_CAPS_pubmethodBeginReceiveBatch(Int32, AsyncCallback, Object)

Begins an asynchronous operation to receive a batch of message.

System_CAPS_pubmethodBeginReceiveBatch(Int32, TimeSpan, AsyncCallback, Object)

Begins an asynchronous operation to receive a batch of message.

System_CAPS_pubmethodClose()

Sends a cleanup message to Service Bus to signal the completion of the usage of an entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodCloseAsync()

Sends a cleanup message asynchronously to Service Bus to signal the completion of the usage of an entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodComplete(Guid)

Completes the receive operation on a message.

System_CAPS_pubmethodCompleteAsync(Guid)

Asynchronously completes the receive operation on a message.

System_CAPS_pubmethodCompleteBatch(IEnumerable<Guid>)

Completes the receive operation on a batch of message.

System_CAPS_pubmethodCompleteBatchAsync(IEnumerable<Guid>)

Asynchronously completes the receive operation on a batch of message.

System_CAPS_pubmethodDeadLetter(Guid)

Moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDeadLetter(Guid, IDictionary<String, Object>)

Moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDeadLetter(Guid, String, String)

Moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDeadLetterAsync(Guid)

Asynchronously moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDeadLetterAsync(Guid, IDictionary<String, Object>)

Asynchronously moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDeadLetterAsync(Guid, String, String)

Asynchronously moves the undelivered message to the dead letter queue.

System_CAPS_pubmethodDefer(Guid)

Indicates that the receiver wants to defer the processing for the message.

System_CAPS_pubmethodDefer(Guid, IDictionary<String, Object>)

Indicates that the receiver wants to defer the processing for the message.

System_CAPS_pubmethodDeferAsync(Guid)

Asynchronously defer the processing of the message.

System_CAPS_pubmethodDeferAsync(Guid, IDictionary<String, Object>)

Asynchronously defer the processing of the message.

System_CAPS_pubmethodEndAbandon(IAsyncResult)

Ends the asynchronous operation to abandon the message and relinquish its lock.

System_CAPS_pubmethodEndClose(IAsyncResult)

Finishes an asynchronous operation to close the message client entity.(Inherited from MessageClientEntity.)

System_CAPS_pubmethodEndComplete(IAsyncResult)

Ends the asynchronous operation to complete receipt of a message.

System_CAPS_pubmethodEndCompleteBatch(IAsyncResult)

Ends the asynchronous operation to complete receipt of a batch message.

System_CAPS_pubmethodEndDeadLetter(IAsyncResult)

Ends an asynchronous operation to move the message to the dead letter queue.

System_CAPS_pubmethodEndDefer(IAsyncResult)

Ends an asynchronous operation to defer receipt of a message.

System_CAPS_pubmethodEndPeek(IAsyncResult)

Ends an asynchronous operation to peek a message.

System_CAPS_pubmethodEndPeekBatch(IAsyncResult)

Ends an asynchronous operation to peek a batch of message.

System_CAPS_pubmethodEndReceive(IAsyncResult)

Ends an asynchronous operation to receive a message.

System_CAPS_pubmethodEndReceiveBatch(IAsyncResult)

Ends an asynchronous operation to receive a batch of message.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFault()

For internal use only. Do not inherit from this class.(Inherited from ClientEntity.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_protmethodSystem_CAPS_staticGetLockToken(BrokeredMessage)

Gets the lock token bound to the message.

System_CAPS_protmethodSystem_CAPS_staticGetLockTokens(IEnumerable<BrokeredMessage>)

Gets the collection of lock tokens from the specified collection of messages.

System_CAPS_protmethodGetProperty<T>()

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodOnAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, TimeSpan)

Executes upon calling the Abandon operation.

System_CAPS_protmethodOnAbort()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnAbandon or BeginAbandon operation.

System_CAPS_protmethodOnBeginClose(TimeSpan, AsyncCallback, Object)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginComplete(TrackingContext, IEnumerable<ArraySegment<Byte>>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnComplete or BeginComplete operation.

System_CAPS_protmethodOnBeginComplete(TrackingContext, IEnumerable<Guid>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnComplete or BeginComplete operation.

System_CAPS_protmethodOnBeginDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, String, String, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnDeadLetter or BeginDeadLetter operation.

System_CAPS_protmethodOnBeginDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnDefer or BeginDefer operation.

System_CAPS_protmethodOnBeginOpen(TimeSpan, AsyncCallback, Object)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginPeek(TrackingContext, Int64, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the BeginPeek operation.

System_CAPS_protmethodOnBeginRenewMessageLocks(TrackingContext, IEnumerable<Guid>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnBegin operation for lock messages.

System_CAPS_protmethodOnBeginTryReceive(TrackingContext, IEnumerable<Int64>, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

System_CAPS_protmethodOnBeginTryReceive(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

System_CAPS_protmethodOnBeginTryReceive2(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

System_CAPS_protmethodOnBeginTryReceiveEventData(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnTryReceive or BeginTryReceive operation for the event data.

System_CAPS_protmethodOnClose(TimeSpan)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnClosed()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnComplete(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes upon calling the Complete operation.

System_CAPS_protmethodOnDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, String, String, TimeSpan)

Executes upon calling the DeadLetter operation.

System_CAPS_protmethodOnDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String, Object>, TimeSpan)

Executes upon calling the Defer operation.

System_CAPS_protmethodOnEndAbandon(IAsyncResult)

Executes the end abandon action.

System_CAPS_protmethodOnEndClose(IAsyncResult)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnEndComplete(IAsyncResult)

Executes the end complete action.

System_CAPS_protmethodOnEndDeadLetter(IAsyncResult)

Executes the end move to dead letter queue action.

System_CAPS_protmethodOnEndDefer(IAsyncResult)

Executes the end defer action.

System_CAPS_protmethodOnEndOpen(IAsyncResult)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnEndPeek(IAsyncResult)

Executes the EndPeek operation.

System_CAPS_protmethodOnEndRenewMessageLocks(IAsyncResult)

Executes the EndRenew action for message locks.

System_CAPS_protmethodOnEndTryReceive(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

System_CAPS_protmethodOnEndTryReceive2(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

System_CAPS_protmethodOnEndTryReceiveEventData(IAsyncResult, IEnumerable<EventData>)

Executes the EndTryReceive action for the event data.

System_CAPS_protmethodOnFaulted()

(Inherited from ClientEntity.)

System_CAPS_pubmethodOnMessage(Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump.

System_CAPS_pubmethodOnMessageAsync(Func<BrokeredMessage, Task>, OnMessageOptions)

Asynchronously processes a message in an event-driven message pump.

System_CAPS_protmethodOnOpen(TimeSpan)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnOpened()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnPeek(TrackingContext, Int64, Int32, TimeSpan)

Executes upon calling the Peek operation.

System_CAPS_protmethodOnRenewMessageLocks(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the Renew action for lock messages.

System_CAPS_protmethodOnTryReceive(TrackingContext, IEnumerable<Int64>, TimeSpan, IEnumerable<BrokeredMessage>)

Executes upon calling the TryReceive operation.

System_CAPS_protmethodOnTryReceive(TrackingContext, Int32, TimeSpan, IEnumerable<BrokeredMessage>)

Executes upon calling the TryReceive operation.

System_CAPS_pubmethodPeek()

Reads the next message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeek(Int64)

Reads the next message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekAsync()

Asynchronously reads the next message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekAsync(Int64)

Asynchronously reads the next message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekBatch(Int32)

Reads the next batch of message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekBatch(Int64, Int32)

Reads the next batch of message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekBatchAsync(Int32)

Asynchronously reads the next batch of message without changing the state of the receiver or the message source.

System_CAPS_pubmethodPeekBatchAsync(Int64, Int32)

Asynchronously reads the next batch of message without changing the state of the receiver or the message source.

System_CAPS_pubmethodReceive()

Receives a BrokeredMessage from the current queue or topic.

System_CAPS_pubmethodReceive(Int64)

Receives a message from the current queue or topic.

System_CAPS_pubmethodReceive(TimeSpan)

Receives a BrokeredMessage from the current queue or topic.

System_CAPS_pubmethodReceiveAsync()

Asynchronously receives a message from the current queue or topic.

System_CAPS_pubmethodReceiveAsync(Int64)

Asynchronously receives a message from the current queue or topic.

System_CAPS_pubmethodReceiveAsync(TimeSpan)

Asynchronously receives a message from the current queue or topic.

System_CAPS_pubmethodReceiveBatch(IEnumerable<Int64>)

Receives a batch of messages.

System_CAPS_pubmethodReceiveBatch(Int32)

Receives a batch of messages.

System_CAPS_pubmethodReceiveBatch(Int32, TimeSpan)

Receives a batch of messages.

System_CAPS_pubmethodReceiveBatchAsync(IEnumerable<Int64>)

Asynchronously receives a batch of messages.

System_CAPS_pubmethodReceiveBatchAsync(Int32)

Asynchronously receives a batch of messages.

System_CAPS_pubmethodReceiveBatchAsync(Int32, TimeSpan)

Asynchronously receives a batch of messages.

System_CAPS_protmethodThrowIfClosed()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposed()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposedOrImmutable()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposedOrNotOpen()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfFaulted()

(Inherited from ClientEntity.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

Any public static (Shared in Visual Basic) members of this type are thread safe. Instance members are also guaranteed to be thread safe.

Although you can use the QueueClient class to send and receive messages without creating a MessageReceiver object, you can also use MessageSender and MessageReceiver to create a sender and receiver on an entity. However, note that you can only use a MessageReceiver to receive messages from a queue or subscription; you cannot receive messages or listen for messages from a topic. Similarly, you can only use a MessageSender to send messages to a queue or topic; you cannot send messages to a subscription. Note that the default message receive mode is PeekLock, which ensures reliable message receiving.

When you create a MessageReceiver for subscriptions, the entityPath parameter is of the form topicPath/subscriptions/subscriptionName.

The following example receives a message from the queue created in the MessageSender example:

Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty); 

MessagingFactory factory = MessagingFactory.Create(serviceUri, credentials); 

MessageReceiver myMessageReceiver = factory.CreateMessageReceiver(queueName);

BrokeredMessage message;
while ((message = myMessageReceiver.Receive(new TimeSpan(hours: 0, minutes: 1, seconds: 5))) != null)
{
    Console.WriteLine(
    string.Format(
    "Message received: Id = {0}, Body = {1}", message.MessageId, message.GetBody<string>()));
    message.Complete();
}

Return to top
Visa:
© 2015 Microsoft