DivyaShailesh
DivyaShailesh

Reputation: 11

Camel Azure Storage Blob consumer not working as expected (blob consumes continuously)

I have written a simple route to consume a blob from Azure Blob Storage in camel (version 3.12.0) as given below:

 from("azure-storage-blob://{{camelazure}}/{{container1}}?blobName=test.json&serviceClient=#client")
                .to({{filePath}});

The blob gets consumed non-stop and the route does not stop. Any inputs on how to implement idempotency while consuming from blob storage ?

Upvotes: 0

Views: 540

Answers (1)

DivyaShailesh
DivyaShailesh

Reputation: 11

As suggested by Pasi Österman, the below solution worked well when we know the blob name to be downloaded and processed.

from("timer://readBlob?fixedRate=true&period=60000")
    .to("azure-storage-blob://{{camelazure}}/{{container1}}?blobName=test.json&operation=getBlob&serviceClient=#client")
    .process(exchange -> {
        InputStream inputStream = exchange.getMessage().getBody(InputStream.class);
        exchange.getIn().setBody(IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()));
    })
    .to("file:{{filePath}}")
    .to("azure-storage-blob://{{camelazure}}/{{container1}}?blobName=processed/test.json&operation=uploadBlockBlob&serviceClient=#client")
    .to("azure-storage-blob://{{camelazure}}/{{container1}}?blobName=test.json&operation=deleteBlob&serviceClient=#client");

Upvotes: 1

Related Questions