Sobes.tech
Senior

Who orchestrated the entire process — who understood what message needed to be sent to Kafka and to initiate the calculation?

sobes.tech AI

Answer from AI

Process orchestration, including decisions about when to send messages to Kafka and initiate calculations, is usually implemented in the business logic layer or in a separate orchestrator component.

This can be a service that:

  • Monitors the application's state and events.
  • Makes decisions based on business rules.
  • Forms and sends messages to Kafka.
  • Launches computational tasks or calls relevant services.

For example, in a microservices architecture, this could be a separate coordinator service or a workflow engine that manages the sequence of actions.

In Java, it might look like this:

@Service
public class ProcessOrchestrator {
    private final KafkaTemplate<String, String> kafkaTemplate;
    private final CalculationService calculationService;

    public void handleEvent(Event event) {
        if (shouldSendMessage(event)) {
            kafkaTemplate.send("topic", event.getData());
        }
        if (shouldStartCalculation(event)) {
            calculationService.startCalculation(event.getParameters());
        }
    }

    private boolean shouldSendMessage(Event event) {
        // decision logic
    }

    private boolean shouldStartCalculation(Event event) {
        // decision logic
    }
}

Thus, this component "understands" the business logic and is responsible for coordinating interactions between systems and components.

Who orchestrated the entire process — who understood… - sobes.tech