Camel - How to use properties set in a file in a route written in xml











up vote
1
down vote

favorite












i've encountered some trouble using properties in a camel xml route without spring. I'm trying to use the properties in 'to uri' tag and so far i've achieved this result:



<to uri="properties:{{url}}{{delimiter}}throwExceptionOnFailure=false?locations=endpoint.properties"/>


url is the key for something like 'http4://localhost:8080' and delimiter is the key for '?'. I used this workaround to be able to use throwExceptionOnFailure option for the http4 component and avoid a FailedToCreateRouteException.
Is there another way to not get the exception? I'm also trying to get another solution using simple and recipientList, but until now i got only errors.



Thank you in advance










share|improve this question




























    up vote
    1
    down vote

    favorite












    i've encountered some trouble using properties in a camel xml route without spring. I'm trying to use the properties in 'to uri' tag and so far i've achieved this result:



    <to uri="properties:{{url}}{{delimiter}}throwExceptionOnFailure=false?locations=endpoint.properties"/>


    url is the key for something like 'http4://localhost:8080' and delimiter is the key for '?'. I used this workaround to be able to use throwExceptionOnFailure option for the http4 component and avoid a FailedToCreateRouteException.
    Is there another way to not get the exception? I'm also trying to get another solution using simple and recipientList, but until now i got only errors.



    Thank you in advance










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      i've encountered some trouble using properties in a camel xml route without spring. I'm trying to use the properties in 'to uri' tag and so far i've achieved this result:



      <to uri="properties:{{url}}{{delimiter}}throwExceptionOnFailure=false?locations=endpoint.properties"/>


      url is the key for something like 'http4://localhost:8080' and delimiter is the key for '?'. I used this workaround to be able to use throwExceptionOnFailure option for the http4 component and avoid a FailedToCreateRouteException.
      Is there another way to not get the exception? I'm also trying to get another solution using simple and recipientList, but until now i got only errors.



      Thank you in advance










      share|improve this question















      i've encountered some trouble using properties in a camel xml route without spring. I'm trying to use the properties in 'to uri' tag and so far i've achieved this result:



      <to uri="properties:{{url}}{{delimiter}}throwExceptionOnFailure=false?locations=endpoint.properties"/>


      url is the key for something like 'http4://localhost:8080' and delimiter is the key for '?'. I used this workaround to be able to use throwExceptionOnFailure option for the http4 component and avoid a FailedToCreateRouteException.
      Is there another way to not get the exception? I'm also trying to get another solution using simple and recipientList, but until now i got only errors.



      Thank you in advance







      xml properties apache-camel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 11:43

























      asked Nov 8 at 11:16









      heartlex

      107




      107
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You need to ensure that the property placeholder is loaded before you can use it.



          PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
          props.setLocation("classpath:yourfile.properties:);


          in XML :



          <bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
          <property name="location" value="classpath:yourfile.properties" />
          </bean>





          share|improve this answer





















          • i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
            – heartlex
            Nov 8 at 13:46










          • my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
            – heartlex
            Nov 8 at 13:54










          • bean element should be outside of camelContext element. Are you using Blueprint XML?
            – fg78nc
            Nov 8 at 14:48










          • i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
            – heartlex
            Nov 8 at 15:41










          • Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
            – fg78nc
            Nov 8 at 16:06













          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',
          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/3.0/"u003ecc by-sa 3.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%2f53206651%2fcamel-how-to-use-properties-set-in-a-file-in-a-route-written-in-xml%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








          up vote
          0
          down vote



          accepted










          You need to ensure that the property placeholder is loaded before you can use it.



          PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
          props.setLocation("classpath:yourfile.properties:);


          in XML :



          <bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
          <property name="location" value="classpath:yourfile.properties" />
          </bean>





          share|improve this answer





















          • i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
            – heartlex
            Nov 8 at 13:46










          • my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
            – heartlex
            Nov 8 at 13:54










          • bean element should be outside of camelContext element. Are you using Blueprint XML?
            – fg78nc
            Nov 8 at 14:48










          • i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
            – heartlex
            Nov 8 at 15:41










          • Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
            – fg78nc
            Nov 8 at 16:06

















          up vote
          0
          down vote



          accepted










          You need to ensure that the property placeholder is loaded before you can use it.



          PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
          props.setLocation("classpath:yourfile.properties:);


          in XML :



          <bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
          <property name="location" value="classpath:yourfile.properties" />
          </bean>





          share|improve this answer





















          • i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
            – heartlex
            Nov 8 at 13:46










          • my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
            – heartlex
            Nov 8 at 13:54










          • bean element should be outside of camelContext element. Are you using Blueprint XML?
            – fg78nc
            Nov 8 at 14:48










          • i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
            – heartlex
            Nov 8 at 15:41










          • Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
            – fg78nc
            Nov 8 at 16:06















          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          You need to ensure that the property placeholder is loaded before you can use it.



          PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
          props.setLocation("classpath:yourfile.properties:);


          in XML :



          <bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
          <property name="location" value="classpath:yourfile.properties" />
          </bean>





          share|improve this answer












          You need to ensure that the property placeholder is loaded before you can use it.



          PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
          props.setLocation("classpath:yourfile.properties:);


          in XML :



          <bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
          <property name="location" value="classpath:yourfile.properties" />
          </bean>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 12:59









          fg78nc

          2,1981516




          2,1981516












          • i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
            – heartlex
            Nov 8 at 13:46










          • my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
            – heartlex
            Nov 8 at 13:54










          • bean element should be outside of camelContext element. Are you using Blueprint XML?
            – fg78nc
            Nov 8 at 14:48










          • i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
            – heartlex
            Nov 8 at 15:41










          • Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
            – fg78nc
            Nov 8 at 16:06




















          • i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
            – heartlex
            Nov 8 at 13:46










          • my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
            – heartlex
            Nov 8 at 13:54










          • bean element should be outside of camelContext element. Are you using Blueprint XML?
            – fg78nc
            Nov 8 at 14:48










          • i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
            – heartlex
            Nov 8 at 15:41










          • Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
            – fg78nc
            Nov 8 at 16:06


















          i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
          – heartlex
          Nov 8 at 13:46




          i tried to use a bean inside the camel config file, but i got an xml error so i changed strategy. i give it another try
          – heartlex
          Nov 8 at 13:46












          my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
          – heartlex
          Nov 8 at 13:54




          my camel config file begins with the tag routes, not beans, and i can't load a bean inside it
          – heartlex
          Nov 8 at 13:54












          bean element should be outside of camelContext element. Are you using Blueprint XML?
          – fg78nc
          Nov 8 at 14:48




          bean element should be outside of camelContext element. Are you using Blueprint XML?
          – fg78nc
          Nov 8 at 14:48












          i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
          – heartlex
          Nov 8 at 15:41




          i started from the exampe camel-example-servlet-tomcat-no-spring where i have a camel-config.xml which contains only routes (the file itself starts with the tag routes). No camel context or blueprint is provided. Changing approach using spring with a camelContext gives me the possibility to use beans (i used a propertyPlaceholder though). I'm only curious to know if another way is possible in the first scenario i mentioned
          – heartlex
          Nov 8 at 15:41












          Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
          – fg78nc
          Nov 8 at 16:06






          Add to beforeStart method of the MyLifecycle class the following lines : PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
          – fg78nc
          Nov 8 at 16:06




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206651%2fcamel-how-to-use-properties-set-in-a-file-in-a-route-written-in-xml%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

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)