I want to create have java program, which runs continously. This would hit check a table in Database for any new records and if there is anything it would post a message to another service. It would keep track of how many messages were posted and how many were completed at any point of time.I should have the ability to stop this service. When a stop sequence is initiated, it should wait till all the messages are processed and shutdown. I am looking for inputs on how to invoke the java program as service and the second part (stopping the service). I dont want to Java wrapper service or commons daemon api.
There's no built-in support in Java for running as a service, so you will have to do something to make your code run as a service. One way is to use one of the several existing third-party libraries that "wrap" your Java code in a service.
If you do not like that, you can write your own code. It will not be Java code (no built-in service support, remember), but will be native C or C++ code.