public class AsyncConnection extends Object implements Connection
Instead of synchronously sending each event to a connection, use a ThreadPool to establish the connection and submit the event.
| Constructor and Description |
|---|
AsyncConnection(Connection actualConnection,
ExecutorService executorService)
Creates a connection which will rely on an executor to send events.
|
public AsyncConnection(Connection actualConnection, ExecutorService executorService)
Will propagate the close() operation.
actualConnection - connection used to send the events.executorService - executorService used to process events, if null, the executorService will automatically
be set to Executors.newSingleThreadExecutor()public void send(Event event)
The event will be added to a queue and will be handled by a separate Thread later on.
send in interface Connectionevent - captured event to add in Sentry.public void close()
throws IOException
Closing the AsyncConnection will attempt a graceful shutdown of the executorService with a
timeout of SHUTDOWN_TIMEOUT, allowing the current events to be submitted while new events will
be rejected.
If the shutdown times out, the executorService will be forced to shutdown.
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2012–2014. All rights reserved.