12 Enabling ECID in Coherence Logs
Coherence logs will include ECID only if the client already has an activated ECID prior to calling Coherence operations. The ECID may be passed from another component or obtained in the client code. To activate the context, use the get and activate methods on the oracle.dms.context.ExecutionContext interface in the Coherence client code. The ECID will be attached to the executing thread. Use the deactivate method to release the context, for example:
Example 12-1 Using a DMS Context in Coherence Client Code
// fragment: requires oracle.dms.context.ExecutionContext from the host runtime
var context = ExecutionContext.get();
context.activate();
try {
// set request context values, then perform the Coherence operation
} finally {
context.deactivate();
}ECID logging will occur only on the node where the client is running. If a client request is processed on some other node and an exception is thrown by Coherence, then the remote error will be returned to the originating node and it will be logged on the Coherence client. The log message will contain the ECID of the request. Messages logged on the remote node will not contain the ECID.
To include the ECID in a Coherence log message, see Changing the Log Message Format in Developing Applications with Oracle Coherence.
Activation belongs to the current execution context and must be balanced on every path. This fragment requires the host DMS runtime. Do not assume an ECID, authenticated Subject or thread-local context automatically propagates to an arbitrary executor or virtual thread; use the host framework supported context propagation and verify the receiving context. ECID is diagnostic correlation, not an authenticated identity.