4

I have a micronaut application that is supposed to run a SQS listener in one container and a regular HTTP server on the other. How do I achieve this via configuration? I can use the following app properties to enable/disable the listener:

micronaut:
  jms:
    sqs:
      enabled: true

How do I enable/disable the web server?

PS: I was able to disable the web server in spring boot with spring.main.web-application-type=NONE. But I am not able to find the relevant setting in micronaut.

  • Looks like this can be achieved using configuration per environment. The environment could be 1.listener 2.web. But you may have to enable the controllers based on the condition. More info here https://docs.micronaut.io/latest/guide/#environments – null Oct 07 '21 at 08:07
  • @null I can do it conditionally as well within properties file, but my question still stands. What property do I have to set/unset to disable the http server? – I.M.MK.XLII Oct 07 '21 at 09:36
  • Do you have a netty based Micronaut app (as opposed to CLI, gRPC etc) and at startup you want to conditionally startup netty? – Jeff Scott Brown Oct 07 '21 at 17:46
  • @JeffScottBrown yes, that could solve it for me. – I.M.MK.XLII Oct 08 '21 at 04:11
  • You can create a message driven app or a CLI app (see options at https://micronaut.io/launch) and those don't contain an http server, but that is a separate thing than making a decision at startup time to run an http server or not. – Jeff Scott Brown Oct 08 '21 at 13:14
  • Do you really need to make the http server decision at startup time, or you just want an app without an http server? – Jeff Scott Brown Oct 08 '21 at 13:16
  • @JeffScottBrown what we want to do is run the same app in 2 different modes depending upon some env variable. One that just runs the http server, and another that is just an sqs listener. They are all running on different machines and we don't know which machines beforehand. – I.M.MK.XLII Oct 12 '21 at 04:34

1 Answers1

0

Another idea to propose is based on the premise that your micronaut fires up both the sqs listener and http server everytime. Then you can configure an environment variable that will be read on startup time. Based on this environment variable you can enable or disable beans across the app that are interfaces to the listener or rest apis to the HTTP app. You can use the @Requires on beans, controllers, factories etc.