use of org.eclipse.hono.client.command.CommandAlreadyProcessedException in project hono by eclipse.
the class KafkaBasedCommandContext method release.
@Override
public final void release(final Throwable error) {
Objects.requireNonNull(error);
if (!setCompleted("released")) {
return;
}
final Span span = getTracingSpan();
TracingHelper.logError(span, "command could not be delivered or processed", error);
final ServiceInvocationException mappedError = StatusCodeMapper.toServerError(error);
final int status = mappedError.getErrorCode();
Tags.HTTP_STATUS.set(span, status);
if (isRequestResponseCommand() && !(error instanceof CommandAlreadyProcessedException) && !(error instanceof CommandToBeReprocessedException)) {
final String errorMessage = Optional.ofNullable(ServiceInvocationException.getErrorMessageForExternalClient(mappedError)).orElse("Temporarily unavailable");
sendDeliveryFailureCommandResponseMessage(status, errorMessage, span, error).onComplete(v -> span.finish());
} else {
span.finish();
}
}
Aggregations