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
xml properties apache-camel
add a comment |
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
xml properties apache-camel
add a comment |
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
xml properties apache-camel
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
xml properties apache-camel
edited Nov 8 at 11:43
asked Nov 8 at 11:16
heartlex
107
107
add a comment |
add a comment |
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>
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 ofcamelContext
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 tobeforeStart
method of theMyLifecycle
class the following lines :PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
– fg78nc
Nov 8 at 16:06
|
show 5 more comments
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>
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 ofcamelContext
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 tobeforeStart
method of theMyLifecycle
class the following lines :PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
– fg78nc
Nov 8 at 16:06
|
show 5 more comments
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>
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 ofcamelContext
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 tobeforeStart
method of theMyLifecycle
class the following lines :PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
– fg78nc
Nov 8 at 16:06
|
show 5 more comments
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>
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>
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 ofcamelContext
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 tobeforeStart
method of theMyLifecycle
class the following lines :PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class); props.setLocation("classpath:yourfile.properties:);
– fg78nc
Nov 8 at 16:06
|
show 5 more comments
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 ofcamelContext
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 tobeforeStart
method of theMyLifecycle
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
|
show 5 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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