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

Instrument mapping between Message Headers and Plain Java Beans

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: extra
    • Environment:

      JDK8

    • Estimated Complexity:
      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

            • Assignee:
              Unassigned
              Reporter:
              adelinor Adelino Rodrigues

              Dates

              • Created:
                Updated:

                Issue deployment