Skip to content

A bunch of examples on how to publish and consume messages via Azure Service Bus broker.

License

Notifications You must be signed in to change notification settings

murilobeltrame/postmen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postmen

A bunch of examples on how to publish and consume messages via Azure Service Bus broker.

Implementation

Implementation Overview

Postmen has two groups of applications
One called Senders, can post messages into a Topic in Azure Service Bus. All these applications post messages to the same Topic called by default postcreated. Other called Receivers, can receive posted messages throught a Topic Subscription. Each kind of application is connected to tis own subscription like:

  • Postmen.Receiver.Console.Core listens postcreatedsubscriptioncore;
  • Postmen.Receiver.Console.Framework listens postcreatedsubscriptionframework;
  • Postmen.Receiver.Functions listens postcreatedsubscriptionfunctions;

Class Diagram

Local Configuration

Cloud infrastructure

To setup broker infrastructure:

# '~' is used to represent the project`s root folder
cd ~/src/environment
az login
terraform init
terraform apply
# to get broker connection string
terraform output BrokerConnectionString

For .Net Framework Apps

.Net Framework apps uses environment variables to manage connection strings
Before run .Net Framework apps, it's necessary to configure local Environment Variables:

# <BrokerConnectionString> got from terraform execution
[System.Environment]::SetEnvironmentVariable('ConnectionStrings:ServiceBus','<BrokerConnectionString>')

For .Net Core Apps

.Net Core apps uses user secrets to manage connection strings.
Before run .Net Core apps, it's necessary to configure user secrets. To do so, inside the .Net Core project folder:

# <BrokerConnectionString> got from terraform execution
dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:ServiceBus" "<BrokerConnectionString>"

For Azure Functions Apps

Before run Azure Functions Apps, it's necessary to create a local configuration file - named local.settings.json - inside the Azure Functions App project folder:

// File local.settings.json
// <BrokerConnectionString> got from terraform execution
{
  //...
  "Values": {
    //...
    "ServiceBusConnectionString": "<BrokerConnectionString>"
  }
}

Running

Notice that you probably wanna run at least one instance of senders and one of receivers. All senders and receivers are connected to the same single broker.

Running .Net Framework Apps

Just open the project in Visual Studio and start the application.

Running .Net Core Apps

.Net Core apps have configuration to set the DOTNET_ENVIRONMENT to Development so the user-secrets mechanism can work correctly (check Properties/launchSettings.json).
To run .Net Core apps you can open the application in Visual Studio or Visual Studio Code and hit run or, inside the project folder:

dotnet run

Running Azure Functions Apps

To run multiple instances of Azure Functions Apps locally, these projects where configure to use non default debug ports. Keep in mind that debuging Sender function will allocate 7072 and Receiver, 7073.
To run Azure Functions Apps you can open the application in Visual Studio or Visual Studio Code and hit run or, insisde the project folder:

func start

Dependencies

Used to create these examples but completly optional:

For .Net Framework Apps

For .Net Core Apps

For Azure Functions Apps

About

A bunch of examples on how to publish and consume messages via Azure Service Bus broker.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks