How they work real time applications in Java?

Good time of day. Would like to know like on a real Java project to solve the following kind of tasks:

1) Has an API, you need to asynchronously process all the arriving messages.
2) There is a set of tasks that need to be done constantly, repeating every minute.

In the project where I work I write in php. 1 point is solved using the server's queue to RabbitMQ queue which are listening at the same time, a lot of casumaro, i.e. hanging of the worker and process it all.
The second paragraph is solved as well by running console her, swirling in an endless loop.
Managing workername is with the help of a supervisor, if you want to add speed, it adds n instances of worker.

The task took just for example, are interested in the concept of solving such problems in Java. Simply put, working as a java real time application, on the same principle are created of different worker and launched separately or otherwise. Due to which increase performance, this is the same heap instance, or something with threads connected? And how are forever running application while (true) {...} and forward or are there more elegant solutions?

Thanks in advance for your answers.
June 10th 19 at 16:06
2 answers
June 10th 19 at 16:08
It all depends on the architect and architecture.
In fact, all virtually the same, taken place, and it planted workeri.
Queues themselves are in any JEE container. Also in any JEE container to run the desired number of workerb. Ie it's all already built into the specification JEE, there are also a bunch of different implementations as queues and containers that support a single API interaction. There are jboss, glassfish, and another dozen implementations. It is so to speak the traditional way. Here we get a unified mechanism for the management, deployment and interaction within the ecosystem.
Also can all the same implement in conjunction with rabbitMQ and just spawn processes as workerb. But you can from the container to be picked up to the same rabbitMQ.

Don't know whether to answer your question.
If I understand correctly, jboss, glassfish - it is about enterprise, I understood, thank you.

But if the application is not the level of the enterprise, but something simpler, where tomcat is enough, there's some standards and best practices? - hillard.Little commented on June 10th 19 at 16:11
Well, you can and within Tomcat run workerb, but it is better not to do it, since tomkat and his ilk type jetty - servlet containers, and aims to work with web.

In this case, either use a lightweight framework like spring, or just write workarou type "do ... while" which run as regular processes on the system.
Yes, with no bans in in your web application to connect to the same rabbitMQ remote or JEE or whatever that left a message queue. Or use actors or even to transmit messages.

There is no single approach, and probably never will. Ways to solve any problem hundreds good different libraries and frameworks are made so that sometimes the main task is to choose the framework that the entire team is ready to lay down his life for 2-3 years :-) - Kasey.Cruickshank commented on June 10th 19 at 16:14
thank you very much for detailed answers, slowly clears the horizon, I will now individually analyze all) - hillard.Little commented on June 10th 19 at 16:17
June 10th 19 at 16:10
ActiveMQ queue
Spring @Scheduled - tasks scheduled

Find more questions by tags Java