Java implementation of the OpAMP client spec.
Warning
This is an incubating feature. Breaking changes can happen on a new release without previous notice and without backward compatibility guarantees.
// Initializing it
RequestService requestService = HttpRequestService.create(OkHttpSender.create("[OPAMP_SERVICE_URL]"));
// RequestService requestService = WebSocketRequestService.create(OkHttpWebSocket.create("[OPAMP_SERVICE_URL]")); // Use this instead to connect to the server via WebSocket.
OpampClient client =
OpampClient.builder()
.putIdentifyingAttribute("service.name", "My service name")
.enableRemoteConfig()
.setRequestService(requestService)
.build(
new OpampClient.Callbacks() {
@Override
public void onConnect(OpampClient client) {}
@Override
public void onConnectFailed(OpampClient client, @Nullable Throwable throwable) {}
@Override
public void onErrorResponse(OpampClient client, ServerErrorResponse errorResponse) {}
@Override
public void onMessage(OpampClient client, MessageData messageData) {
AgentRemoteConfig remoteConfig = messageData.getRemoteConfig();
if (remoteConfig != null) {
// A remote config was received
// After applying it...
client.setRemoteConfigStatus(
new RemoteConfigStatus.Builder()
.status(RemoteConfigStatuses.RemoteConfigStatuses_APPLIED)
.build());
}
}
});
// State update
client.setAgentDescription(new AgentDescription.Builder().build());
// App shutdown
client.close();- Cesar Munoz, Elastic
- Jack Shirazi, Elastic
Learn more about component owners in component_owners.yml.