Skip to content

LeonPatmore/nats-reactor-consumer

Repository files navigation

NATS Reactor Consumer

CircleCI

A reactor library for consuming from NATS.

  • Consumer Client: A generic consuming client.
  • Test Consumer: An example of a SpringBoot service using the client. Used for functional tests.

Monitoring

Monitoring: https://natsdashboard.com/jetstream?url=http%3A%2F%2Flocalhost%3A8222

Grafana: http://localhost:3000/dashboards

Metrics

  • nats_processor_result: A counter for the result of a processed message. Has tag result that can be failed or success.
  • nats_acked: A counter for number of messages acked.

Functional Tests

Here

  • test_simple_message_is_processed: Ensures a message is consumed and acked.
  • test_message_that_errors_goes_to_dlq: A message that continuously errors will go to a DLQ.
  • test_message_that_does_not_ack_in_time_goes_to_dlq: A message that does not ack in time will eventually go to the DLQ.
  • test_message_when_service_dies_it_is_retried: When the consumer dies during processing of a message, this message is retried.

Local Testing

  1. Start NATS locally: cd deployments/local && make start
  2. Build the test consumer: cd nats-reactor-consumer && make docker-build
  3. Build the tests: cd functional-tests && make build
  4. Run the tests: cd functional-tests && make run

Performance Tests

Here

The performance test sends requests to the test consumer and ensures that it processes the expected amount after 5 seconds from the test ending.

  1. Start NATS locally: cd deployments/local && make start
  2. Build the performance test image: cd performance-tests && make build
  3. Start the test consumer: cd nats-reactor-consumer && make docker-run
  4. Run the test: cd performance-tests && make run

Documentation