Skip to content

Producer

Brian Lehnen edited this page Nov 1, 2015 · 6 revisions

Producing messages

The message can be any serializable class. Messages can be sent in a few different ways.

A single message with no additional message metadata
var result = queue.Send(new SimpleMessage {Message = "Hello World"});
A single message with additional metadata, such as a message delay
var data = new AdditionalMessageData();
data.SetDelay(TimeSpan.FromMinutes(1));
var result = queue.Send(new SimpleMessage {Message = "Hello World"}, data);
A collection of messages with or without additional metadata. Note that this operation is not necessarily atomic
var result = queue.Send(messageList);
All of the above commands have async methods as well
var result = await queue.SendAsync(new SimpleMessage {Message = "Hello World"});

All methods return the result of the operation. This includes the following:

  • A boolean indicating if an error occurred
  • An exception containing the error, if an error occurred.
  • Information about the sent message -The Message ID -The correlation ID

Methods that take in a collection of messages return a collection of results. The collection contains a boolean named 'HasErrors' that will indicate if any result failed.

Clone this wiki locally