The task is as follows: write a service that will listen to the state of the mail server via IMAP and receive information about the update on the server.
Of course, using javamail api I can make a request, get information, compare it with the previous state, do it in an infinite timer loop, but my goal is not to store the state, but only to receive information about new letters and somehow process them.
Like that:
setHandler ((mail) -> mail.getSubject ());
Those. set a callback (for example, additionally configuring filters for letters — receive callback from certain senders) and that's it.
Actually, you can write this API yourself, but Java has it all :)))
Can someone advise whether there is a ready-made lib?