I was able to test all of the code created in this milestone on my local machine. The instructions below assume you are running on your local machine. I implemented this on a Mac, so references to the command-line will show as a UNIX shell.
- Kafka and Zookeeper need to be running
- The OrderReceived topic should be created
- The OrderPickedAndPacked topic should be created
- The Notification topic should be created
- The DeadLetterQueue topic should be created
- The Postgress database needs to be running
- The right database, schema and table need to be created: click here for more information
- The Order service needs to be running (assumes you are in the
milestone5/code
folder)
- If this is the first time you are running this code, you will need to setup Go modules
- In your
~/.bash_profile
, make sure you have the following ENV var set: export GO111MODULE=on
and make sure the file is sourced. - Initialize Go modules
$ go mod init
$ go mod tidy
- Run the Order service
$ go run order/main.go
- The Inventory consumer needs to be running (assumes you are in the
milestone5/code
folder)
- If this is the first time you are running this code, you will need to setup Go modules
- In your
~/.bash_profile
, make sure you have the following ENV var set: export GO111MODULE=on
and make sure the file is sourced. - Initialize Go modules
$ go mod init
$ go mod tidy
- Run the Inventory consumer service
$ go run inventory/main.go
- The Warehouse consumer needs to be running (assumes you are in the
milestone5/code
folder)
- If this is the first time you are running this code, you will need to setup Go modules
- In your
~/.bash_profile
, make sure you have the following ENV var set: export GO111MODULE=on
and make sure the file is sourced. - Initialize Go modules
$ go mod init
$ go mod tidy
- Run the Warehouse consumer service
$ go run warehouse/main.go
- The Notification consumer needs to be running (assumes you are in the
milestone5/code
folder)
- If this is the first time you are running this code, you will need to setup Go modules
- In your
~/.bash_profile
, make sure you have the following ENV var set: export GO111MODULE=on
and make sure the file is sourced. - Initialize Go modules
$ go mod init
$ go mod tidy
- Run the Notification consumer service
$ go run notification/main.go
- The Shipper consumer needs to be running (assumes you are in the
milestone5/code
folder)
- If this is the first time you are running this code, you will need to setup Go modules
- In your
~/.bash_profile
, make sure you have the following ENV var set: export GO111MODULE=on
and make sure the file is sourced. - Initialize Go modules
$ go mod init
$ go mod tidy
- Run the Shipper consumer service
$ go run shipper/main.go
- Send a HTTP request to the order service:
$ curl -v -H "Content-Type: application/json" -d '{"id":"6e042f29-350b-4d51-8849-5e36456dfa48","products":[{"productCode":"12345","quantity":2}],"customer":{"firstName":"Tom","lastName":"Hardy","emailAddress":"tom.hardy@email.com","shippingAddress":{"line1":"123 Anywhere St","city":"Anytown","state":"AL","postalCode":"12345"}}}' http://localhost:8080/orders
- You should see output in the console of the order service, and no errors. You can also check the contents of the OrderReceived topic in Kafka.
$ $KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic OrderReceived --from-beginning
- You can also check the contents of the Notification topic in Kafka.
$ $KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic Notification --from-beginning
- You should see output in the console of the inventory consumer, and no errors.
- You should see output in the console of the warehouse consumer, and no errors.
- You should see output in the console of the notification consumer, and no errors.
- To check the the shipping consumer, you will need to manually publish a message to the OrderPickedAndPacked topic in Kafka.
$ $KAFKA_HOMEbin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic OrderPickedAndPacked
Then you can past a payload like this
{"EventBase":{"EventID":"4a651ef8-a851-4d77-a58b-3d8af748a570","EventTimestamp":"2020-08-16T16:03:05.258542-04:00"},"EventBody":{"id":"c6b37316-b4da-4b25-94c8-14c08bad95e6","products":[{"productCode":"12345","quantity":2}],"customer":{"firstName":"Tom","lastName":"Hardy","emailAddress":"tom.hardy@email.com","shippingAddress":{"line1":"123 Anywhere St","city":"Anytown","state":"AL","postalCode":"12345"}}}}
- You should see output in the console of the shipper consumer, and no errors.