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,
boolean gracefulShutdown,
long shutdownTimeout)
Creates a connection which will rely on an executor to send events.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventSendCallback(EventSendCallback eventSendCallback)
Add a callback that is called when an exception occurs while attempting to
send events to the Sentry server.
|
void |
close()
.
|
void |
send(Event event)
Sends an event to the Sentry server.
|
public AsyncConnection(Connection actualConnection, ExecutorService executorService, boolean gracefulShutdown, long shutdownTimeout)
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()
gracefulShutdown
- Indicates whether or not the shutdown operation should be managed by a ShutdownHook.shutdownTimeout
- timeout for graceful shutdown of the executor, in milliseconds.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 Connection
event
- captured event to add in Sentry.public void addEventSendCallback(EventSendCallback eventSendCallback)
Connection
addEventSendCallback
in interface Connection
eventSendCallback
- callback instancepublic void close() throws IOException
Closing the AsyncConnection
will attempt a graceful shutdown of the executorService
with a
timeout of shutdownTimeout
, 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 Closeable
close
in interface AutoCloseable
IOException
Copyright © 2012–2018. All rights reserved.