I am developing a library that includes a Log4J appender that asynchronously transmits occasions to some remote server. Whenever a log statement is created, the appender will asynchronously record the big event right into a local queue that your pool of customers will retrieve and send towards the remote.

The completely in-memory solution is always to produce a BlockingQueue which may handle the concurrency problem. However, I would like for that queue to become endured to ensure that when the remote server isn't available I do not grow the queue unbounded or begin to discard messages within the situation of the bounded queue.

I believed of utilizing an embedded H2 database to keep the occasions in your area after which make use of a polling mechanism to retrieve occasions and send towards the remote. I'd prefer to make use of a BlockingQueue rather than poll a database table.

Is JMS the solution?

EDIT:

If JMS may be the answer, also it appears to become going this way, does anybody have tips about a light-weight, embeddable JMS solution that may be set up to simply accept messages in-process? Quite simply, I don't want to, and perhaps won't be permitted to, open a TCP socket which to pay attention.

EDIT:

I have got ActiveMQ embedded now also it appears to become working. Thanks all.

Bob Lee open acquired a simple disk backed queue some time back, https://github.com/square/retrofit/blob/master/modules/android/src/retrofit/io/QueueFile.java -- might be useful, and it is certainly a great deal simpler introducing than JMS if you're able to accept local sturdiness.

These kinds is stand alone -- it may be replicated and copied and pasted.

You could utilize JMS to asynchronously send messages to some remote machine (presuming it may receive them obviously), Log4j includes a JMS Appender you should use with this.

You are able to certainly use JMS for this function. So far as I realize you're while using Log4J JMS appender. This component transmits messages to pre-set up JMS destination (typically queue). You are able to configure this queue to become endured. Within this situation all messages placed in to the queue is going to be instantly saved in certain endured store (typically database.). Regrettably this configuration is vendor specific (is dependent around the JMS vendor), truly really is easy. Please make reference to the documentation individuals JMS provider.