1 Reply Latest reply on Mar 15, 2012 1:12 PM by Tom Cunningham

    Enriching a message from CSV

    Billy Sjöberg Newbie

      Hi all,

       

      I have a usecase where I'd like to use the Enrich EIP pattern to query data from a csv file and alter a value inside my message in flow.

      My current flow is to transform an incoming xml message with smooks/freemarker. However some data is not available in the incoming message and must be queried against a static csv file based by a field in the incoming message.

       

      This is very similar to the enrich-db pattern I've seen in smooks with the only difference being that my static data is not in a database but a CSV file.

       

      Is this pattern supported in the esb and where should I put the enrichment logic?

       

      The options I've contemplated so far are:

       

      1) Bind a bean in smooks to a class which does the lookup against a preloaded map based on csv.

      2) Use an auxiliary ESB action after the transformation

      3) Somehow utilize Smooks with multiple input sources (one being the message, the other the static csv file). Perform the query inside Freemarker and "join" based on the incoming data field as key.

       

      1 and 2 seems to hackish as this is a very common pattern, so my hope is that something similar to alternative 3 exists.

      Has anyone done this and knows of a clean and non-intrusive way to do it?

        • 1. Re: Enriching a message from CSV
          Tom Cunningham Master

          Check out the huge-split-enrich-transform-route quickstart - in particular 01_split_enrich_transform_route/smooks_configs/database/ref-data.xml.      I think it does what you are looking for, although with a database, not with a CSV file.        If the CSV part of your requirements is something that can be tweaked, it might make sense to store it in a DB rather than a CSV file - if not, you might be able to front your CSV with JDBC or JPA and use the datasource instead.