-2

I am writing a Java program which will keep on listening to JMS/ActiveMQ queue for any messages. When there is a message posted on the queue, this program will pick up the message and process it. This program has a main() method. Now I want to deploy this program in JBoss/Wildfly. Already there are some web application deployed on JBoss. I want to deploy this program also on JBoss to avoid manual start ups. Whenever the JBoss server starts, this program also should run and listen to queue.

If main method cannot be used I need some advice on alternative solution to this requirement.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Mohamed
  • 75
  • 10
  • It helped me to get some ideas. But now I am trying to implement a notification service which will be triggered on timely basis rather than queue monitoring. So i am planning to use Quartz shceduler as many suggest this. thanks for your comments. @JustinBertram – Mohamed Apr 25 '19 at 06:10

1 Answers1

1

In application servers, you can't run a java application. You must deploy a web application as a war or ear.

What you can do:

1) Transform your java standalone application in a web application and define a servlet. This servlet will start your process. So, in this case, when the server starts, it will deploy your package (war or ear), initialize your servlet and then start yout process. 2) Transform your java standalone application in a web application with a scheduler (linux quartz) to start your process. This is better than the first option because you don't have to create a servet.

PS: When you have to run a java standalone application, in general, we use other services to do this job (as Control-M or cron tab in linux)

thiagotrss
  • 129
  • 4
  • Great. Will try the second method. – Mohamed Apr 25 '19 at 05:57
  • Can I get some examples or link to refer for implementing Quartz scheduler in cluster (Active-Active ) environment. When the first job starts, then the second node should not start this job. – Mohamed Apr 25 '19 at 06:12
  • @Akram the quartz api is capable to execute in cluster environments. It's uses tables in database to control the multiples executions. Look this thread https://stackoverflow.com/questions/12626380/quartz-scheduler-in-cluster-environment – thiagotrss Apr 25 '19 at 16:30
  • Great and useful replies. That helped me a lot. – Mohamed Apr 30 '19 at 08:54