census-rm-pubsub-adapter
An adapter service to translate inbound PubSub messages into the standard format of RM JSON events and republish them on to our events exchange.
Prerequisites
Requires golang >= 1.13 installed
Configuration
The required environment configuration variables are:
RABBIT_HOST
RABBIT_PORT
RABBIT_USERNAME
RABBIT_PASSWORD
EQ_RECEIPT_PROJECT
OFFLINE_RECEIPT_PROJECT
QM_UNDELIVERED_SUBSCRIPTION_PROJECT
PPO_UNDELIVERED_SUBSCRIPTION_PROJECT
Config to run locally against docker-compose dependencies
LOG_LEVEL=DEBUG
RABBIT_HOST=localhost
RABBIT_PORT=7672
RABBIT_USERNAME=guest
RABBIT_PASSWORD=guest
EQ_RECEIPT_PROJECT=project
PUBSUB_EMULATOR_HOST=localhost:8539
EQ_RECEIPT_PROJECT=project
OFFLINE_RECEIPT_PROJECT=offline-project
QM_UNDELIVERED_SUBSCRIPTION_PROJECT=qm-undelivered-project
PPO_UNDELIVERED_SUBSCRIPTION_PROJECT=ppo-undelivered-project
RECEIPT_ROUTING_KEY=goTestReceiptQueue
UNDELIVERED_ROUTING_KEY=goTestUndeliveredQueue
FULFILMENT_CONFIRMED_PROJECT=fulfilment-project
Config to run locally against docker dev
LOG_LEVEL=INFO
RABBIT_HOST=localhost
RABBIT_PORT=6672
RABBIT_USERNAME=guest
RABBIT_PASSWORD=guest
EQ_RECEIPT_PROJECT=project
PUBSUB_EMULATOR_HOST=localhost:8538
EQ_RECEIPT_PROJECT=project
OFFLINE_RECEIPT_PROJECT=offline-project
QM_UNDELIVERED_SUBSCRIPTION_PROJECT=qm-undelivered-project
PPO_UNDELIVERED_SUBSCRIPTION_PROJECT=ppo-undelivered-project
FULFILMENT_CONFIRMED_PROJECT=fulfilment-project
Running the tests
Run
make build-test
This will run the formatter, build and units tests then spin up the dependencies with docker-compose and run the service integration tests.
Debugging the tests
To run the integration tests in an IDE
- Run
make up-dependencies
to start up the dependencies with docker-compose.
- Set the environment variable
PUBSUB_EMULATOR_HOST=localhost:8539
in your IDE run configuration
- Run the test in debug mode
Run make format
to automatically format the project using gofmt
Build the docker image
With
make docker
Run in docker-compose
Start the service and dependencies
Run make up
to start the pubsub-adapter and dependencies through docker-compose
You can then run make logs
to tail the logs
Post in a test message
You can send a test message onto the pubsub emulator with the tools script
PUBSUB_EMULATOR_HOST=localhost:8539 go run tools/publish_message.go
You should see the pubsub adapter log that it has processed the message and see the rabbit messages it produced in the rabbit management UI at http://localhost:17672 (login: guest, guest).