Skip to content

Latest commit

 

History

History
107 lines (74 loc) · 2.65 KB

File metadata and controls

107 lines (74 loc) · 2.65 KB

Dapr Bindings (HTTP)

In this quickstart, you'll create a microservice to demonstrate Dapr's bindings API to work with external systems as inputs and outputs. The service listens to input binding events from a system CRON and then outputs the contents of local data to a PostgreSQL output binding.

Visit this link for more information about Dapr and Bindings.

Note: This example leverages only HTTP REST. If you are looking for the example using the Dapr SDK click here.

This quickstart includes one service:

  • Javascript/Node.js service bindings

Prerequisites


Run and initialize PostgreSQL container

  1. Open a new terminal, change directories to ../../db, and run the container with Docker Compose:
cd ../../db
docker compose up -d

Run Javascript service with Dapr

  1. Open a new terminal window, change directories to ./batch in the quickstart directory and install dependencies:
cd ./batch
npm install
cd ..

  1. Run the Javascript service app with Dapr:
dapr run -f .

The -f flag runs the application using the Multi-App Run configuration defined in dapr.yaml, automatically starting both the application and its Dapr sidecar.

The cron input binding triggers the service every 10 seconds, and the service writes records to PostgreSQL using the output binding.


Verify Data Persistence

  1. Open a new terminal window and run the following command to check the rows in the database:
docker exec postgres psql -U postgres -d orders -c "SELECT * FROM orders;"