How to get headers from one route to another route - Camel JavaDslCamel Route/ActiveMQ unmarshaling JSON and sending to methodsCamel Inter module coordination - dependencyCamel check header value after splitUnable to configure “Keep Alive” in Camel HTTP componentAccess enum.valueof() from apache camel routeRetrieve soap header from apache camel exchange objectApache Camel - Exchange body is null after upgrading spring boot versioncamel-http4 post not working I get no responseSpring Boot Camel Route - get data from rest endpointHow to trigger camel route from client request?

How often is duct tape used during crewed space missions?

What is Cousin Itt in The Addams Family?

Output Distinct Factor Cuboids

Floating Point XOR

Are there any instances in Tanach of Lashon Hara said purely for non-constructive purposes?

In Bb5 systems against the Sicilian, why does White exchange their b5 bishop without playing a6?

Is Yang not precluded from conduting his "UBI experiment" as an electoral candidate?

Carroll's interpretation of 1-forms

Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?

Cemented carbide swords - worth it?

Why do we need to use transistors when building an OR gate?

What was the earliest microcomputer Logo language implementation?

Hobby function generators

What the did the controller say during my approach to land (audio clip)?

How can I create folders in folders in terminal

How could artificial intelligence harm us?

What to do as a player when ranger animal companion dies

How to convey to the people around me that I want to disengage myself from constant giving?

Inquiry answerer

Are lay articles good enough to be the main source of information for PhD research?

Preventing the ears from getting clogged on descent to Barcelona

Can a business put whatever they want into a contract?

Should the pagination be reset when changing the order?

Abilities interrupting effects on a cast card



How to get headers from one route to another route - Camel JavaDsl


Camel Route/ActiveMQ unmarshaling JSON and sending to methodsCamel Inter module coordination - dependencyCamel check header value after splitUnable to configure “Keep Alive” in Camel HTTP componentAccess enum.valueof() from apache camel routeRetrieve soap header from apache camel exchange objectApache Camel - Exchange body is null after upgrading spring boot versioncamel-http4 post not working I get no responseSpring Boot Camel Route - get data from rest endpointHow to trigger camel route from client request?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have camel rest endpoint with two params and when I send request it activates first route ("direct:amq"), where I get message from activeMq.



The headers here are okay, but this route activates another route ("direct:post)" and the headers there are missing.



I want to get the urlToPost Header from the first route in to the second.



 rest("/getFromActiveMq").produces("application/json")
.get()
.param()
.name("urlToPost")
.type(RestParamType.query)
.dataType("String")
.endParam()
.param()
.name("getactivemq")
.type(RestParamType.query)
.dataType("String")
.endParam()
.to("direct:amq");

from("direct:amq").streamCaching()
.startupOrder(2)
.log("My activemq is " + "$in.header.getactivemq")
.log("My urlToPost is " + "$in.header.urlToPost")
.setHeader("myHeader")
.header("$in.header.urlToPost")
.log("My urlToPost Changed header is " + "$header.myHeader")
.process(exchange ->
String header = exchange.getIn().getHeader("urlToPost", String.class);
System.out.println(header);
exchange.getIn().setHeader("myShittyHeader", header);

Map<String, Object> hdr = exchange.getIn()
.getHeaders();
for (Map.Entry<String, Object> entry : hdr.entrySet())
System.out.println(entry.getKey() + "/" + entry.getValue());

)
.pollEnrich()
.simple("activemq://$in.header.getactivemq")
.onCompletion()
.log("My body is : " + "$body")
.to("direct:post");

from("direct:post").tracing()
.process(exchange -> exchange.getIn()
.setBody(exchange.getIn()
.getBody()))
.convertBodyTo(String.class)
.process(exchange ->
Map<String, Object> hdr = exchange.getIn()
.getHeaders();
for (Map.Entry<String, Object> entry : hdr.entrySet())
System.out.println(entry.getKey() + "/" + entry.getValue());

)
.log("My urlToPost BEFORE SETTING HEADERS is " + "$in.header.urlToPost")
.setHeader("Content-Type", constant("application/json"))
.setHeader("Accept", constant("application/json"))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.log("My urlToPost AFTER SETTING HEADERS is " + "$in.header.urlToPost")
// .log("My HTTP_URI is: " + "$in.header.urlToPost")
// .to("http4://urlToPost")
// .to("direct:nothing");
.enrich()
.simple("http4://urlToPost");


I found that after:




.pollEnrich()
.simple("activemq://$in.header.getactivemq")




Headers are gone










share|improve this question
































    2















    I have camel rest endpoint with two params and when I send request it activates first route ("direct:amq"), where I get message from activeMq.



    The headers here are okay, but this route activates another route ("direct:post)" and the headers there are missing.



    I want to get the urlToPost Header from the first route in to the second.



     rest("/getFromActiveMq").produces("application/json")
    .get()
    .param()
    .name("urlToPost")
    .type(RestParamType.query)
    .dataType("String")
    .endParam()
    .param()
    .name("getactivemq")
    .type(RestParamType.query)
    .dataType("String")
    .endParam()
    .to("direct:amq");

    from("direct:amq").streamCaching()
    .startupOrder(2)
    .log("My activemq is " + "$in.header.getactivemq")
    .log("My urlToPost is " + "$in.header.urlToPost")
    .setHeader("myHeader")
    .header("$in.header.urlToPost")
    .log("My urlToPost Changed header is " + "$header.myHeader")
    .process(exchange ->
    String header = exchange.getIn().getHeader("urlToPost", String.class);
    System.out.println(header);
    exchange.getIn().setHeader("myShittyHeader", header);

    Map<String, Object> hdr = exchange.getIn()
    .getHeaders();
    for (Map.Entry<String, Object> entry : hdr.entrySet())
    System.out.println(entry.getKey() + "/" + entry.getValue());

    )
    .pollEnrich()
    .simple("activemq://$in.header.getactivemq")
    .onCompletion()
    .log("My body is : " + "$body")
    .to("direct:post");

    from("direct:post").tracing()
    .process(exchange -> exchange.getIn()
    .setBody(exchange.getIn()
    .getBody()))
    .convertBodyTo(String.class)
    .process(exchange ->
    Map<String, Object> hdr = exchange.getIn()
    .getHeaders();
    for (Map.Entry<String, Object> entry : hdr.entrySet())
    System.out.println(entry.getKey() + "/" + entry.getValue());

    )
    .log("My urlToPost BEFORE SETTING HEADERS is " + "$in.header.urlToPost")
    .setHeader("Content-Type", constant("application/json"))
    .setHeader("Accept", constant("application/json"))
    .setHeader(Exchange.HTTP_METHOD, constant("POST"))
    .log("My urlToPost AFTER SETTING HEADERS is " + "$in.header.urlToPost")
    // .log("My HTTP_URI is: " + "$in.header.urlToPost")
    // .to("http4://urlToPost")
    // .to("direct:nothing");
    .enrich()
    .simple("http4://urlToPost");


    I found that after:




    .pollEnrich()
    .simple("activemq://$in.header.getactivemq")




    Headers are gone










    share|improve this question




























      2












      2








      2








      I have camel rest endpoint with two params and when I send request it activates first route ("direct:amq"), where I get message from activeMq.



      The headers here are okay, but this route activates another route ("direct:post)" and the headers there are missing.



      I want to get the urlToPost Header from the first route in to the second.



       rest("/getFromActiveMq").produces("application/json")
      .get()
      .param()
      .name("urlToPost")
      .type(RestParamType.query)
      .dataType("String")
      .endParam()
      .param()
      .name("getactivemq")
      .type(RestParamType.query)
      .dataType("String")
      .endParam()
      .to("direct:amq");

      from("direct:amq").streamCaching()
      .startupOrder(2)
      .log("My activemq is " + "$in.header.getactivemq")
      .log("My urlToPost is " + "$in.header.urlToPost")
      .setHeader("myHeader")
      .header("$in.header.urlToPost")
      .log("My urlToPost Changed header is " + "$header.myHeader")
      .process(exchange ->
      String header = exchange.getIn().getHeader("urlToPost", String.class);
      System.out.println(header);
      exchange.getIn().setHeader("myShittyHeader", header);

      Map<String, Object> hdr = exchange.getIn()
      .getHeaders();
      for (Map.Entry<String, Object> entry : hdr.entrySet())
      System.out.println(entry.getKey() + "/" + entry.getValue());

      )
      .pollEnrich()
      .simple("activemq://$in.header.getactivemq")
      .onCompletion()
      .log("My body is : " + "$body")
      .to("direct:post");

      from("direct:post").tracing()
      .process(exchange -> exchange.getIn()
      .setBody(exchange.getIn()
      .getBody()))
      .convertBodyTo(String.class)
      .process(exchange ->
      Map<String, Object> hdr = exchange.getIn()
      .getHeaders();
      for (Map.Entry<String, Object> entry : hdr.entrySet())
      System.out.println(entry.getKey() + "/" + entry.getValue());

      )
      .log("My urlToPost BEFORE SETTING HEADERS is " + "$in.header.urlToPost")
      .setHeader("Content-Type", constant("application/json"))
      .setHeader("Accept", constant("application/json"))
      .setHeader(Exchange.HTTP_METHOD, constant("POST"))
      .log("My urlToPost AFTER SETTING HEADERS is " + "$in.header.urlToPost")
      // .log("My HTTP_URI is: " + "$in.header.urlToPost")
      // .to("http4://urlToPost")
      // .to("direct:nothing");
      .enrich()
      .simple("http4://urlToPost");


      I found that after:




      .pollEnrich()
      .simple("activemq://$in.header.getactivemq")




      Headers are gone










      share|improve this question
















      I have camel rest endpoint with two params and when I send request it activates first route ("direct:amq"), where I get message from activeMq.



      The headers here are okay, but this route activates another route ("direct:post)" and the headers there are missing.



      I want to get the urlToPost Header from the first route in to the second.



       rest("/getFromActiveMq").produces("application/json")
      .get()
      .param()
      .name("urlToPost")
      .type(RestParamType.query)
      .dataType("String")
      .endParam()
      .param()
      .name("getactivemq")
      .type(RestParamType.query)
      .dataType("String")
      .endParam()
      .to("direct:amq");

      from("direct:amq").streamCaching()
      .startupOrder(2)
      .log("My activemq is " + "$in.header.getactivemq")
      .log("My urlToPost is " + "$in.header.urlToPost")
      .setHeader("myHeader")
      .header("$in.header.urlToPost")
      .log("My urlToPost Changed header is " + "$header.myHeader")
      .process(exchange ->
      String header = exchange.getIn().getHeader("urlToPost", String.class);
      System.out.println(header);
      exchange.getIn().setHeader("myShittyHeader", header);

      Map<String, Object> hdr = exchange.getIn()
      .getHeaders();
      for (Map.Entry<String, Object> entry : hdr.entrySet())
      System.out.println(entry.getKey() + "/" + entry.getValue());

      )
      .pollEnrich()
      .simple("activemq://$in.header.getactivemq")
      .onCompletion()
      .log("My body is : " + "$body")
      .to("direct:post");

      from("direct:post").tracing()
      .process(exchange -> exchange.getIn()
      .setBody(exchange.getIn()
      .getBody()))
      .convertBodyTo(String.class)
      .process(exchange ->
      Map<String, Object> hdr = exchange.getIn()
      .getHeaders();
      for (Map.Entry<String, Object> entry : hdr.entrySet())
      System.out.println(entry.getKey() + "/" + entry.getValue());

      )
      .log("My urlToPost BEFORE SETTING HEADERS is " + "$in.header.urlToPost")
      .setHeader("Content-Type", constant("application/json"))
      .setHeader("Accept", constant("application/json"))
      .setHeader(Exchange.HTTP_METHOD, constant("POST"))
      .log("My urlToPost AFTER SETTING HEADERS is " + "$in.header.urlToPost")
      // .log("My HTTP_URI is: " + "$in.header.urlToPost")
      // .to("http4://urlToPost")
      // .to("direct:nothing");
      .enrich()
      .simple("http4://urlToPost");


      I found that after:




      .pollEnrich()
      .simple("activemq://$in.header.getactivemq")




      Headers are gone







      spring-boot apache-camel spring-camel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 15:20







      xmlParser

















      asked Mar 28 at 13:09









      xmlParserxmlParser

      7451 gold badge6 silver badges23 bronze badges




      7451 gold badge6 silver badges23 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          The pollEnrich merges your current Exchange with another message. That means it is in effect an Aggregator.



          If you don't provide an aggregation strategy, Camel uses by default a simple body aggregation. This is the reason why you lose your headers.



          You have to configure a pre-existing or implement your own aggregation strategy that respects the headers of one or both messages during aggregation.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398467%2fhow-to-get-headers-from-one-route-to-another-route-camel-javadsl%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1
















            The pollEnrich merges your current Exchange with another message. That means it is in effect an Aggregator.



            If you don't provide an aggregation strategy, Camel uses by default a simple body aggregation. This is the reason why you lose your headers.



            You have to configure a pre-existing or implement your own aggregation strategy that respects the headers of one or both messages during aggregation.






            share|improve this answer





























              1
















              The pollEnrich merges your current Exchange with another message. That means it is in effect an Aggregator.



              If you don't provide an aggregation strategy, Camel uses by default a simple body aggregation. This is the reason why you lose your headers.



              You have to configure a pre-existing or implement your own aggregation strategy that respects the headers of one or both messages during aggregation.






              share|improve this answer



























                1














                1










                1









                The pollEnrich merges your current Exchange with another message. That means it is in effect an Aggregator.



                If you don't provide an aggregation strategy, Camel uses by default a simple body aggregation. This is the reason why you lose your headers.



                You have to configure a pre-existing or implement your own aggregation strategy that respects the headers of one or both messages during aggregation.






                share|improve this answer













                The pollEnrich merges your current Exchange with another message. That means it is in effect an Aggregator.



                If you don't provide an aggregation strategy, Camel uses by default a simple body aggregation. This is the reason why you lose your headers.



                You have to configure a pre-existing or implement your own aggregation strategy that respects the headers of one or both messages during aggregation.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 16:14









                burkiburki

                2,6671 gold badge6 silver badges20 bronze badges




                2,6671 gold badge6 silver badges20 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398467%2fhow-to-get-headers-from-one-route-to-another-route-camel-javadsl%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript