Hiroshking
Hiroshking

Reputation: 11

Enriching XML Data Before Saving to Database in Apache Camel

I'm working on a project using Apache Camel and Spring Boot, and I'm trying to save data to Elasticsearch. I have two XML files:

The first file contains a huge list of products. The second file contains detailed information about each product. Initially, I created a route that reads from the first file, tokenizes and streams the products, unmarshals them into objects, and then saves them to Elasticsearch. Later, I wanted to enrich the product data with the details from the second file before saving to Elasticsearch.

My first idea was to create another route that reads from the second file and call it within my first route. I planned to pass the product ID to this second route and search for the corresponding details in the second file (e.g., using XPath). However, after exploring various methods (including pollEnrich), I couldn't find a way to make this approach work effectively.

To get a working solution, I ended up creating:

A route that reads the second file and saves all the details to a MongoDB database. Another route that reads the product file, tokenizes and unmarshals it, and then calls a bean to enrich the product data by querying MongoDB for the details before saving the enriched data to Elasticsearch. This solution works, but I’m wondering:

Is this the best approach for my use case? Should I continue exploring ways to make the first idea (enriching directly from the second file during the first route) work? Any guidance or suggestions would be greatly appreciated!

Upvotes: 0

Views: 30

Answers (0)

Related Questions