> For the complete documentation index, see [llms.txt](https://xmlking.gitbook.io/micro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xmlking.gitbook.io/micro/develop/advanced/pubsub.md).

# Pub Sub

```bash
export GOOGLEPUBSUB_PROJECT_ID=my-project-id
gcloud beta emulators pubsub start --project=$GOOGLEPUBSUB_PROJECT_ID --host-port=localhost:8085
# Create topic `mkit.service.emailer` (optional)
# Note: Second time when you run below service, it will automatically create topic
gcloud pubsub topics create mkit.service.emailer
```

Run service

```bash
export GOOGLEPUBSUB_PROJECT_ID=my-project-id
# PUBSUB_EMULATOR_HOST for Dev
$(gcloud beta emulators pubsub env-init)
export PUBSUB_EMULATOR_HOST=localhost:8085

# set GOOGLE_APPLICATION_CREDENTIALS for Prod
# export GOOGLE_APPLICATION_CREDENTIALS=~/path/your_project_credentials.json
export MICRO_BROKER=googlepubsub
make run-emailer ARGS="--server_address=localhost:8080"
```
