Custom Topic Ordering

A common customization to the LOAD operation is to enforce the order in which certain topics are processed.

We can achieve this by creating a List of Sets of topics from the incoming request and then process them in the desired order. This can be done by overriding the existing LOAD operation.

Configuration

public class CustomOperationsConfig {

	@Bean
	public IDlcOperation loadOperation(DlcLoadOperationsService loadOperationsService) {
		return new CustomLoadOperation(loadOperationsService);
	}
}

Custom Operation

class CustomLoadOperation implements IDlcOperation {
    private final DlcLoadOperationsService loadOperationsService;

    public CustomLoadOperation(DlcLoadOperationsService loadOperationsService) {
        this.loadOperationsService = loadOperationsService;
    }

    @Override
    public String getName() {
        return DefaultDlcOperationsConfig.LOAD;
    }

    @Override
    public DlcResponse process(DlcRequest request) {
        Set<String> incomingTopics = loadOperationsService.resolveAliases(request);
        List<Set<String>> organizedTopics = processForTopics(incomingTopics);

        Map<String, ITopicParsingReport> parsingReport = new HashMap<>();
        for (Set<String> topics : organizedTopics) {
            if (!topics.isEmpty()) {
                Map<String, ITopicParsingReport> partialReport = loadOperationsService.load(request.getTable(), topics, request.getScope());
                parsingReport.putAll(partialReport);
            }
        }

        return DlcResponse.builder().parsingReport(parsingReport).build();
    }

    List<Set<String>> organizeTopics(Set<String> topics) {
        // Custom logic to order topics
    }
}