Sobes.tech
Senior

What approaches are there to handle unstable integration that may not respond from a minute to a day?

sobes.tech AI

Answer from AI

To work with unstable integration that may respond with a delay from a minute to a day, several approaches are used:

  • Asynchronous processing and message queues: Instead of synchronous calls, use a queue (e.g., Kafka, RabbitMQ) to send requests and process responses as they arrive.

  • Retry with exponential backoff: On errors or timeouts, retry requests with increasing delays to avoid overwhelming the integration.

  • Caching and idempotency: Store request results and ensure idempotency of operations to prevent duplication on retries.

  • Monitoring and alerts: Set up monitoring for delays and errors to respond promptly to issues.

  • Splitting requests into smaller parts: If possible, break large requests into smaller ones to reduce load and speed up processing.

  • Using callback/webhook: If supported by the integration, use callback notifications instead of polling continuously.

Example of using a queue with asynchronous processing in Java with CompletableFuture:

CompletableFuture.supplyAsync(() -> callExternalService())
    .thenAccept(response -> processResponse(response))
    .exceptionally(ex -> { logError(ex); return null; });

Thus, the system is non-blocking and can process responses as they arrive.

What approaches are there to handle unstable… - sobes.tech