3.5 Return an Acknowledgment (Ack) Response

This topic describes how to return an acknowledgment (Ack) response after processing an interconnect event.

Upon completion of domain processing, the handler must return an Ack object to signal the processing outcome to the Connector Service.

Ack Class Definition

@Builder
public record Ack(String recordId, Status status, String message) {

    public enum Status { RECEIVED, SUCCESS, FAILED }

    public static Ack success(String recordId) {
        return new Ack(recordId, Status.SUCCESS, "ok");
    }

    public static Ack received(String recordId) {
        return new Ack(recordId, Status.RECEIVED, null);
    }

    public static Ack failed(String recordId, String msg) {
        return new Ack(recordId, Status.FAILED, msg);
    }
}

Usage Examples

// Acknowledge successful processing
return Ack.success(recordId);

// Acknowledge processing failure
return Ack.failed(recordId, "ERR_VALIDATION_FAILED");

Tip: Always use a well-defined, namespaced error code (e.g., ERR_VALIDATION_FAILED) instead of a free-text message. This enables locale-aware translation on the consumer side, ensures consistency across domain implementations, and improves traceability during event reconciliation and incident investigation.

Integration Checklist — Discovery Service

Table 3-2 Integration Checklist — Discovery Service

Step Action
1 Add connector dependency to build.gradle.
2 Enable component scanning for the connector package.
3 Configure system parameters in Interconnect.
4 Implement the Interconnect Event Handler<T> interface.
5 Return appropriate Ack responses from the event handler.

Additional Notes

  • Asynchronous processing (wantsAsync = true) is not yet supported. The method must return false.
  • DTO binding is performed automatically using Jackson's ObjectMapper. Custom conversion logic can be applied by overriding assembleDto().
  • Ensure the domain application name is registered correctly in the Discovery Service before enabling service-based data exchange.