.NET Core Azure Service Bus Send and Receive Message in Session Enabled Subscription

Samuel Hutama
Oct 20, 2018 · 3 min read

Prerequsite

Azure Service Bus Icon.

Session Enabled Subscription — Receiver Code

Subscription with session enabled.
“It is not possible for an entity that requires sessions to create a non-sessionful message receiver”.

Session Enabled Subscription — Sender Code

//// Create a new message to send to the topic.
string messageBody = $"Message {i}";
var message = new Message(Encoding.UTF8.GetBytes(messageBody));//// Set the SessionId with a random Guid.
message.SessionId = Guid.NewGuid().ToString();
//// Write the body of the message to the console.
Console.WriteLine($"Sending message: {messageBody}");
//// Send the message to the topic.
await topicClient.SendAsync(message);
Samuel Hutama

Written by

Samuel is a Full Stack Developer who is working at @PaladorTeam.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade