Search in sources :

Example 1 with CommandAlreadyProcessedException

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();
    }
}
Also used : CommandAlreadyProcessedException(org.eclipse.hono.client.command.CommandAlreadyProcessedException) CommandToBeReprocessedException(org.eclipse.hono.client.command.CommandToBeReprocessedException) ServiceInvocationException(org.eclipse.hono.client.ServiceInvocationException) Span(io.opentracing.Span)

Aggregations

Span (io.opentracing.Span)1 ServiceInvocationException (org.eclipse.hono.client.ServiceInvocationException)1 CommandAlreadyProcessedException (org.eclipse.hono.client.command.CommandAlreadyProcessedException)1 CommandToBeReprocessedException (org.eclipse.hono.client.command.CommandToBeReprocessedException)1