Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13302

Instrument mapping between Message Headers and Plain Java Beans

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Trivial
    • Resolution: Won't Fix
    • None
    • None
    • extra
    • JDK8

    • Unknown

    Description

      When developing Processor implementations to be used in Camel routes, some portion of the code is devoted to retrieving data from Message headers, and after the actual process takes place, setting the resulting headers in the Message.

      As this manual binding of headers to java bean properties is custom, it needs to be verified in unit tests. When talking about a few processors to implement, it is not at all an issue. But when you have a high number of processors, a consistent and tested approach is preferable to the custom code repeated in every processor.

      This issue is raised to introduce a new feature for declaratively mapping message headers to Plain Java bean properties in the style of the [at]Column JPA annotation.

      A mapper instantiated from the Plain Java bean class, then populates the Java bean properties:

      mapper.fromHeaders(headers, myObj);

       

      At the end headers can be enriched/modified from the java bean:

      mapper.toHeaders(myObj, headers);

      This allows the Camel Processor implementation to be less verbose, and the binding becomes more consistent against implementations.

      I developed a prototype which illustrates the principles above using headers in the form of a Map<String, Object> : see https://github.com/adelinor/messaging-header-mapper

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            adelinor Adelino Rodrigues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: