Best way to handle huge number operation in AEM

38 Views Asked by At

I have 10000 paths(AEM paths) in excel and want to get the path and make a http connection call. Since it is a heavy operation I am planning to use Sling Job Manager and Job Consumer.

public class BulkOpeationJobConsumer implements JobConsumer {

    private static final Logger LOG = LoggerFactory.getLogger(BulkOpeationJobConsumer.class);

    @Reference
    ResourceResolverFactory resourceResolverFactory;

    @Override
    public JobResult process(Job job) {
        try {

            
            String path = (String) job.getProperty("path");

            URI uri = URI.create(path);
            HttpRequest request = HttpRequest.newBuilder().uri(uri).timeout(Duration.ofSeconds(2)).build();

            ...
            return JobResult.OK;
        } catch (Exception e) {
            LOG.info("\n Error in Job Consumer : {}  ", e.getMessage());
            return JobResult.FAILED;
        }
    }
}

I am calling this sling job consumer from the servlet. This JobResult method will have 10000 paths to process. I just want to check if this is the correct way to handle or if there is any better way to manage this?

I am planning to use Batch Processing method but I have no idea to create a multiple batches. Should I create multiple job consumer for this ?Any ideas and suggestions ?

0

There are 0 best solutions below