public class AppEngineAsyncConnection extends Object implements Connection
Instead of synchronously sending each event, use a the App Engine queue system to establish the connection and send the event.
Google App Engine serialises the tasks before queuing them, to keep a link between the task and the
AppEngineAsyncConnection associated, a register of the instances of AppEngineAsyncConnection is
kept in APP_ENGINE_ASYNC_CONNECTIONS.
This register is populated when a new instance of AppEngineAsyncConnection is created and the connection
is removed from the register when it has been closed with close().
The register works based on identifier defined by the user. There is no ID conflict handling, the user is expected
to manage the uniqueness of those ID.
| Constructor and Description |
|---|
AppEngineAsyncConnection(String id,
Connection actualConnection)
Creates a connection which will rely on an executor to send events.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEventSendCallback(EventSendCallback eventSendCallback) |
void |
close()
.
|
void |
send(Event event) |
void |
setQueue(String queueName)
Set the queue used to send EventSubmitter tasks.
|
public AppEngineAsyncConnection(String id, Connection actualConnection)
Will propagate the close() operation.
id - Identifier of the connection shared across all the instances of the application.actualConnection - Connection used to send the events.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 Connectionpublic void addEventSendCallback(EventSendCallback eventSendCallback)
addEventSendCallback in interface Connectionpublic void close()
throws IOException
Closing the AppEngineAsyncConnection will gracefully remove every task created earlier from the queue.
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void setQueue(String queueName)
queueName - name of the queue to use.Copyright © 2012–2017. All rights reserved.