Customizing Consul Service Registration

The ConsulConfiguration class features a range of customization options for altering how an instance registers with Consul. You can customize the tags, the retry attempts, the fail fast behaviour and so on.

Notice too that ConsulConfiguration extends DiscoveryClientConfiguration which in turn extends HttpClientConfiguration allowing you to customize the settings for the Consul client, including read timeout, proxy configuration and so on.

For example:

Customizing Consul Registration Configuration

  1. micronaut:
  2. application:
  3. name: hello-world
  4. consul:
  5. client:
  6. registration:
  7. enabled: true
  8. # Alters the tags
  9. tags:
  10. - hello
  11. - world
  12. # Alters the metadata
  13. meta:
  14. some: value
  15. instance_type: t2.medium
  16. # Alters the retry count
  17. retry-count: 5
  18. # Alters fail fast behaviour
  19. fail-fast: false
  20. defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"