You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ron Cecchini <ro...@comcast.net> on 2021/08/24 04:53:14 UTC

How to programmatically reset an application property?

I'm using Camel + Spring Boot.

In my application.properties, I set a property 'foo.bar.size'

In my routes, I use:  {{foo.bar.size}}

In some Java processor code, I use:  camelContext.resolvePropertyPlaceholders("{{foo.bar.size}}")

I now need to reset that property in some Java code and have it take effect immediately.

I read the "Properties" doc and tried a couple of things... but I'm missing the magic sauce.

How do I reset an application property?

Thank you very much.

Re: How to programmatically reset an application property?

Posted by Vyacheslav Boyko <ma...@gmail.com>.
Look into Spring application properties locations 
https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.files

Your users can specify properties in command line and external file.
___
Best regards,
Vyacheslav.
Ron Cecchini <ro...@comcast.net> 24 августа 2021 г. 17:46:06 написал:

> Thank you, Vyacheslav.
>
> I suppose it's not something I really need - although it would have been nice.
>
> I have to implement a way for users to change some of the default 
> properties (after startup) and have them persist.
>
> I already implemented a class to specially handle these several properties 
> that could be dynamically changed. (they don't persist however)
>
> Then I thought, "If I could change the *actual* application property, this 
> would be easier to do..."
>
> However, I would still have the issue of how to persist these config 
> (property) changes; i.e. these settings have to take effect upon a 
> subsequent restart and override the settings in the application.properties.
>
> It looks like there might (?) be something I could use in the "Properties" 
> component - specifying multiple properties locations or files or something. 
>  Maybe the idea is that I have a bit of custom code that persists these few 
> properties to a small properties file (my.properties), and upon restart 
> Spring first loads application.properties and *then* my.properties?
>
> Thanks again.
>
>> On 08/24/2021 1:33 AM Вячеслав Бойко <ma...@gmail.com> wrote:
>>
>>
>> It seems you are doing it wrong.
>> What is the intention of your doing?
>>
>> How do you use placeholders in Camel routes? If you place them into
>> endpoints' URLs you could not change their values to take effect
>> immediately. You have to reset the whole Camel context. It leads to stop
>> all routes, reinit them and start again. It will take a time. Is it a thing
>> you really need?
>>
>> Any way you can put all needed properties in class fields to make them change.
>> ___
>> Best wishes,Vyacheslav.
>>
>> Ron Cecchini <ro...@comcast.net> 24 августа 2021 г. 07:53:29 написал:
>>
>> > I'm using Camel + Spring Boot.
>> >
>> > In my application.properties, I set a property 'foo.bar.size'
>> >
>> > In my routes, I use:  {{foo.bar.size}}
>> >
>> > In some Java processor code, I use:
>> > camelContext.resolvePropertyPlaceholders("{{foo.bar.size}}")
>> >
>> > I now need to reset that property in some Java code and have it take effect
>> > immediately.
>> >
>> > I read the "Properties" doc and tried a couple of things... but I'm missing
>> > the magic sauce.
>> >
>> > How do I reset an application property?
>> >
>> > Thank you very much.


Re: How to programmatically reset an application property?

Posted by Ron Cecchini <ro...@comcast.net>.
Thank you, Vyacheslav.  

I suppose it's not something I really need - although it would have been nice.

I have to implement a way for users to change some of the default properties (after startup) and have them persist.

I already implemented a class to specially handle these several properties that could be dynamically changed. (they don't persist however)

Then I thought, "If I could change the *actual* application property, this would be easier to do..."

However, I would still have the issue of how to persist these config (property) changes; i.e. these settings have to take effect upon a subsequent restart and override the settings in the application.properties.

It looks like there might (?) be something I could use in the "Properties" component - specifying multiple properties locations or files or something.  Maybe the idea is that I have a bit of custom code that persists these few properties to a small properties file (my.properties), and upon restart Spring first loads application.properties and *then* my.properties?

Thanks again.

> On 08/24/2021 1:33 AM Вячеслав Бойко <ma...@gmail.com> wrote:
> 
>  
> It seems you are doing it wrong.
> What is the intention of your doing?
> 
> How do you use placeholders in Camel routes? If you place them into 
> endpoints' URLs you could not change their values to take effect 
> immediately. You have to reset the whole Camel context. It leads to stop 
> all routes, reinit them and start again. It will take a time. Is it a thing 
> you really need?
> 
> Any way you can put all needed properties in class fields to make them change.
> ___
> Best wishes,Vyacheslav.
> 
> Ron Cecchini <ro...@comcast.net> 24 августа 2021 г. 07:53:29 написал:
> 
> > I'm using Camel + Spring Boot.
> >
> > In my application.properties, I set a property 'foo.bar.size'
> >
> > In my routes, I use:  {{foo.bar.size}}
> >
> > In some Java processor code, I use:  
> > camelContext.resolvePropertyPlaceholders("{{foo.bar.size}}")
> >
> > I now need to reset that property in some Java code and have it take effect 
> > immediately.
> >
> > I read the "Properties" doc and tried a couple of things... but I'm missing 
> > the magic sauce.
> >
> > How do I reset an application property?
> >
> > Thank you very much.

Re: How to programmatically reset an application property?

Posted by Вячеслав Бойко <ma...@gmail.com>.
It seems you are doing it wrong.
What is the intention of your doing?

How do you use placeholders in Camel routes? If you place them into 
endpoints' URLs you could not change their values to take effect 
immediately. You have to reset the whole Camel context. It leads to stop 
all routes, reinit them and start again. It will take a time. Is it a thing 
you really need?

Any way you can put all needed properties in class fields to make them change.
___
Best wishes,Vyacheslav.

Ron Cecchini <ro...@comcast.net> 24 августа 2021 г. 07:53:29 написал:

> I'm using Camel + Spring Boot.
>
> In my application.properties, I set a property 'foo.bar.size'
>
> In my routes, I use:  {{foo.bar.size}}
>
> In some Java processor code, I use:  
> camelContext.resolvePropertyPlaceholders("{{foo.bar.size}}")
>
> I now need to reset that property in some Java code and have it take effect 
> immediately.
>
> I read the "Properties" doc and tried a couple of things... but I'm missing 
> the magic sauce.
>
> How do I reset an application property?
>
> Thank you very much.