TransWikia.com

Apache Camel - How to make a value accessible across the entire route?

Stack Overflow Asked by Saud on November 18, 2021

I am trying out a Camel route that queries a table (with primary key), generates a CSV based on the query response and stores the CSV file in Azure storage container. After successfully storing the file in Azure, I need to update a flag in the table that was queried initially. For this purpose I am setting the primary key as part of the header, but after the azure endpoint is executed, the header values are getting reset. So I am not able to retrieve the initial header and hence the primary key value which I need. What is the ideal way to store a value that is accessible during the entire route?

from("direct:processPayroll")
  .setHeader("payrollId",simple("${body.payrollId}"))
  .to("sql:classpath:sql/payroll.sql")
  .marshal(csvFormat)
  .log("${headers}")
  .to("azure-storage-blob://staccount/container?blobName=payroll.csv&operation=uploadBlockBlob")
  .log("${headers}")

One Answer

You can store it in the exchange properties. You can add the value using .setProperty("key","value") and retrieve it using $exchangeProperty("key")

Answered by Sneharghya Pathak on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP