0

Let's say I have an app, started with mvn spring-boot:run, or java -jar myApp.jar.

After a while I want to trigger the execution of a method, from command line. Is it possible ?

I've checked CommandLineRunner but is seems it can only execute code right after the app boot, while I want to execute a method whenever I want.

ThCollignon
  • 976
  • 3
  • 14
  • 31
  • check that link https://stackoverflow.com/questions/15356405/how-to-run-a-command-at-terminal-from-java-program – Slongtong Apr 06 '23 at 12:04
  • that post tells how to run a command from Java, it's the opposite of what I'm looking for – ThCollignon Apr 07 '23 at 07:38
  • 1
    You can try mbeans and cli invocation https://www.baeldung.com/jmx-mbean-shell-access or write custom "terminal controller", like servlet in webapps. Wait commands in loop and handle them. – Slongtong Apr 08 '23 at 10:18

1 Answers1

0

There was Spring RMI (cf this Baeldung article) but it has been deprecated by Spring 5.3, for security reasons.

An answer should lie in Spring integration doc (from this post).

ThCollignon
  • 976
  • 3
  • 14
  • 31