Skip to content

Latest commit

 

History

History

PubSub

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Publish & subscribe messaging demo

Abstract

The purpose of this demo is to show the use of Pub/sub components locally and in the cloud.

Open the demo_pubsub.code-workspace file and click the Open Workspace button in the lower right corner. This will reload your Codespace and scope your Explorer to just the folders needed for this demo.

To provision the infrastructure before the demo execute the following command in the terminal. This code is automatically run by the demo.ps1 script if the -env parameter is passed and ./components/azure/local_secrets.json file is not found.

./demo.ps1 -deployOnly

The workspace consists of one top level folder PubSub. This folder holds the components/azure, components, deploy, and src folders. The components/azure and components folders are in the workspace so you can show the difference between a local component and a component configured for the cloud. The component in the components/azure folder is configured to use Azure Service Bus. In the components/aws folder the component is configured to use AWS SNS/SQS and the local component is configured to use Redis. The point to make comparing the files is that as long as the name of the component does not change the code will work no matter what backing service is used.

Running Demo

The core of the demo is in the sampleRequests.http file. At the top of the file are three demo.ps1 commands. One for running the requests against local resources and two for running against the cloud resources. Copy the desired command and run it in the terminal. This will start Dapr pointing to the appropriate components for the demo. The Dapr run command issued is output if you want to explain during the demo.

Running local

 ./demo.ps1

Running in Azure

 ./demo.ps1 -env azure

Running in AWS

 ./demo.ps1 -env aws

Click the Send Request button above each of the requests to execute them.

Debug Demo

This demo uses the Dapr Extension to enable F5 debugging.

Set breakpoints on lines 9 and 12 of src/Program.cs. Select Run from the View menu then select either the Dapr Local, Dapr Azure, or Dapr AWS launch configuration and press F5. This will start the code and attach the debugger.

Using the sampleRequests.http file click the Send Request button above each of the requests to execute them. Notice with each click the appropriate breakpoint is hit.

Clean Up Demo

When you are done with the demo you can clean up the cloud resources by running the cleanUp.ps1 script using the following commands:

./cleanUp.ps1

If you get port errors run:

lsof -i  

And kill the pid running daprd.