public abstract class AbstractClient extends Object
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractClient.Communicator
Implements the client-service communication machinery.
|
protected class |
AbstractClient.RequestReplyTableEntry
Represents an entry in the request-reply table
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_serverLaunched |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient(String name,
String appName,
String appNameForConfig,
int appVersionMajor,
int appVersionMinor,
Object handlers,
Credentials credentials)
Construct using client name and user event handler container
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close a client.
|
protected abstract EmbeddedServerController |
doGetEmbeddedServerController()
Get the embedded server controller
|
protected abstract MessageHeader |
doGetResponseHeader(MessageView message) |
protected abstract void |
doRegisterFactories(AepEngine engine)
Invoked to register service specific factories
|
protected abstract IRogMessage |
doSetRequestHeader(IRogMessage request,
MessageHeader header) |
protected void |
finalize()
Finalizer method.
|
String |
getName()
Get the name
|
String |
getSourceId()
Get the source id
|
String |
getTransactionId()
Get the current transaction id
|
AbstractClient |
listenForAlerts(boolean val)
Configure the client to listen to alerts
|
AbstractClient |
listenForEvents(boolean val)
Configure the client to listen to events
|
AbstractClient |
listenForHeartbeats(boolean val)
Configure the client to listen to heartbeats
|
void |
onBindingFailed(MessageBusBindingFailedEvent event) |
void |
onEngineStopped(AepEngineStoppedEvent event) |
void |
onHeartbeat(Heartbeat heartbeat) |
void |
onMessagingStarted(AepMessagingStartedEvent event) |
void |
onRequestsChannelDown(AepChannelDownEvent event) |
void |
onRequestsChannelUp(AepChannelUpEvent event) |
void |
open() |
void |
open(AepEngine engine) |
void |
open(Credentials credentials) |
void |
open(Credentials credentials,
AepEngine engine)
Open a client.
|
PingResponse |
ping(PingRequest request)
Ping the service
|
void |
recordTransactionLegTime(String legName,
int procTime)
Record the processing time of a leg in the current transaction
|
void |
sendAlert(AlertRequest request)
Send an alert
|
void |
sendAlert(String headline,
String desc,
Throwable e,
AlertSeverity severity)
Send an alert
|
void |
sendAlert(String desc,
Throwable e,
AlertSeverity severity)
Send an alert
|
protected void |
sendRequest(MessageHeader header,
IRogMessage request,
int partition) |
protected <T> T |
sendRequest(MessageHeader header,
IRogMessage request,
int partition,
boolean waitForReply,
Integer... timeout) |
protected <T> T |
sendRequestAndWaitForReply(MessageHeader header,
IRogMessage request,
int partition,
Integer... timeout) |
void |
setResponseTimeout(int timeout)
Set the client response timeout (in seconds)
|
void |
setTransactionId(String id)
Set the current transaction id
Transaction ids are stored local to threads.
|
protected void |
validateRequest(IRogMessage request) |
protected AbstractClient(String name, String appName, String appNameForConfig, int appVersionMajor, int appVersionMinor, Object handlers, Credentials credentials)
protected abstract void doRegisterFactories(AepEngine engine)
protected abstract EmbeddedServerController doGetEmbeddedServerController()
protected abstract IRogMessage doSetRequestHeader(IRogMessage request, MessageHeader header)
protected abstract MessageHeader doGetResponseHeader(MessageView message)
protected void validateRequest(IRogMessage request)
protected final <T> T sendRequest(MessageHeader header, IRogMessage request, int partition, boolean waitForReply, Integer... timeout)
protected final <T> T sendRequestAndWaitForReply(MessageHeader header, IRogMessage request, int partition, Integer... timeout)
protected final void sendRequest(MessageHeader header, IRogMessage request, int partition)
public final void onRequestsChannelUp(AepChannelUpEvent event)
public final void onRequestsChannelDown(AepChannelDownEvent event)
public final void onBindingFailed(MessageBusBindingFailedEvent event)
public final void onMessagingStarted(AepMessagingStartedEvent event)
public final void onEngineStopped(AepEngineStoppedEvent event)
public final void onHeartbeat(Heartbeat heartbeat)
public final void setResponseTimeout(int timeout)
public final AbstractClient listenForEvents(boolean val)
public final AbstractClient listenForHeartbeats(boolean val)
public final AbstractClient listenForAlerts(boolean val)
public final void open(Credentials credentials, AepEngine engine) throws EServiceException
credentials - A valid set of credentials to use in interacting
with the service.EServiceException - Thrown in case an error is encountered
during the open.
This method opens a connection to the messaging bus used for communication between and server client and service. Eagle supports in-process service execution (i.e. where the service runs in the same process as the client) and out of process service execution. The former uses the 'loopback' bus and is primarily used for testing purposes.
public final void open(AepEngine engine) throws EServiceException
EServiceExceptionpublic final void open(Credentials credentials) throws EServiceException
EServiceExceptionpublic final void open()
throws EServiceException
EServiceExceptionpublic final String getName()
public final String getSourceId()
public final void setTransactionId(String id)
Transaction ids are stored local to threads. Therefore each thread maintains its own transaction id set via this method
public final String getTransactionId()
public final void recordTransactionLegTime(String legName, int procTime)
public final PingResponse ping(PingRequest request) throws EServiceException
EServiceExceptionpublic final void sendAlert(AlertRequest request) throws EServiceException
EServiceExceptionpublic void sendAlert(String headline, String desc, Throwable e, AlertSeverity severity)
public void sendAlert(String desc, Throwable e, AlertSeverity severity)
public final void close()
The caller should invoke this method when done with the client object. This method closes the client's connection to the messaging bus and releases its resources back to the system. The caller should release the client object for garbage collection after this call.
protected void finalize()
throws Throwable
Ensures threads and resources are released when the object is garbage collected. This is only expected to be useful if the user has inadvertently missed closing the client. It is recommended that the user of the client calls close to release resources.
Copyright © 2016 Neeve Research, LLC. All Rights Reserved.