Embed a non-web application at the pier

How can I configure jetty6 to run a non-web application (and not a servlet)? My Java application is a rabbitmq consumer that listens for ampq messages on tcp. I could call init () the call to my main entry point. Is there a better way to do this?

+3
source share
2 answers

Why not provide a trivial servlet that provides a method init()and call your application from the inside? those. wrap it in a servlet wrapper that does almost nothing.

It should not respond to GETs/ POSTsetc. Although you are likely to find this useful and reporting application status with a simple HTML page.

+2
source

, , , , ( )

1. jetty.xml . XML , . <call>
, Jetty - , Jetty.

2. , Jetty LifeCycle ( - AbstractLifeCycle), Server.addLifeCycle()
, Jetty , , Jetty, ..
, , . .

3. , 1, jetty-web.xml ( jetty-env.xml), WAR .
1, Jetty, .

4. , 1, jetty-web.xml. , , , LifeCycle WebAppContext, - .

5. init() initialise-on-startup, ' t URL-. init.

+2

Source: https://habr.com/ru/post/1791007/


All Articles