Camel 2.24.2 : PropertiesComponent override with environment variable - apache-camel

I am attempting use the PropertiesComponent and reading a property file that is in my classpath. I have built a standalone executable jar and I am using the camel Main class - no spring boot.
However, I would like to override one of those properties using environment variables, but it is not working. I am able to override it using the -D, but the documentation indicated that it is possible to override it using an environment variable.
Here is the sample code snippets
Main main = new Main();
main.addRouteBuilder(new HelloRoute());
main.bind("doWork", new DoWork());
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:app.properties");
main.bind("properties", pc);
main.run();
Here is the property file
account.route.id=account_route_get
account.route.get=account_route_get_description
startup_route=false
And here is my route where I am attempting to use it. I am attempting to override the startup_route and it does not work correctly.
rest("/account")
.get("/{name}")
.consumes("application/json")
.outType(Account.class)
.route()
.id("{{account.route.id}}")
.description("{{account.route.get}}")
.autoStartup("{{startup_route}}")
.to("log:{{account.route.get}}?level=INFO")
.to("bean:doWork?method=info(${header.name})")
.endRest()
I found this CAMEL-13502 but it is in a different Camel version, and I am wondering if this is also relevant for Camel 2.24.2
Thanks

I'm guessing you don't want to explicitly call out that you want the variable from the OS environment variables.
If you did want to do that, you could state
.autoStartup("${env:STARTUP_ROUTE}")
but if you are wanting a more dynamic solution, another option could be to create a
choice()
that first checks if the environment variable of that name exists, and if not, to default to the one in the properties file.
.when("${env:STARTUP_ROUTE} != null")
.autoStartup("${env:STARTUP_ROUTE}")
.otherwise()
.autoStartup("{{startup_route}}")
Finally, the Camel documentation of Property Component also states:
You can control these modes using the systemPropertiesMode and environmentVariableMode options on the properties component.
When I ran a sample in my project, I did have the ability to configure the systemPropertiesMode, but I didn't have an option for environmentVariableMode so unsure if that is a feature of a higher level Camel version than I'm using.

Related

how to customize export data(listview) SuiteCRM

I am able to customize if i write create_export_query() in main modules(modules/Leads/lead.php)
but I want this should be upgrade safe code,
can we add create_export_query() method in custom path instead of in lead.php
if so in which file we can add this function other than main module location?
custom/modules/Leads/lead.php will work?
thanks
Naren
custom/modules/Leads/lead.php will not work until you change beanFile location into main bean.
There are 2 ways to do this.
1) Make an extension, custom/Extension/application/Ext/Include, make
a new file CustomLeads.php, put your custom BeanFile location here
for lead module.
2) As export is certainly an action,you may create a custom
controller,ie custom/modules/Leads/controller.php, create a new
function action_export, put your custom code there.
Overriding bean of Suite core module is not recommeneded as it may crack whole system at any point. You should go with #2.

AutoGenerating routeId's in camel

In apache-camel, is there a way to auto generate routeId's overriding the existing ones with route numbers(generated in RouteDefinitionHelper)?
There is to the best of my knowledge no autoGeneration policy on routeNaming you can use, but you could do something similar to this:
private String myURI;
from("jms:queue:" + myURI).routeId("JmsComponent:" + myURI)
.to("....");
By using something like blueprint or spring to inject your variable to the java class you can change your URI and it will adjust the route name accordingly. You could also use the full URI in your private variable then parse the endpointURI yourself and format it for the routeId.
You can specify them directly for routes as well as processors in your routes.
from("direct:start").routeId("MyMainRoute")
.to("direct:out").id("MyOutputProcessor");
These ids will be visible in your jConsole so you can see statistics on your routes and processors as well.

Close method not working in Office

Im trying to use Microsoft.Office.Interop.Word._Document.Close() in a .net 3.5 windows form app.
No matter how much I search here and on Google I cannot find the correct parameters to put in the Close method.
I am using version 14.0.0.0 of Microsoft.Office.Interop.Word and I would like to close the document without saving and ideally ensure that the application can isolate the document thread so that users can still open word documents outside the running application.
See the Close method of the Document class described in MSDN. If you need to omit the parameter and use the default value - pass the Type.Missing parameter.
Try this:
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing = System.Reflection.Missing.Value;
_Document.Close(ref doNotSaveChanges, ref missing, ref missing);
This is the source
I'm not sure if you'll need the middle line or not. It's not from the original source it's from here

Unreal script config - section

I'm modifying utcomp 1.7a for UT 2004.
Here is a problem:
There's a config key word in unreal script, that allow you to save/load variable in ini file, in section called: [package.sectionname].
Problem is that my package is not same as original utcomp's.
So when I'm trying to use some ini settings, UT crating new section, called [mypackage.---], but I want, it to search setting in [originalpackage.---].
Is there any way to set in mutator package name?
I saw modified version of utcomp, that using standart utcomp's settings, so it's possible...but how?
Thanks for any help.
If your class is a child of the base class (in originalpackage), it should automatically load settings from [originalpackage.---] unless you specifically change them in your [mypackage.---] section.
For example, in UTGame.ini the [Engine.GameInfo] section holds settings for all GameInfo subclasses. Further down, [UTGame.UTGame] changes a few settings (like GameDifficulty) and adds a few new ones, but all of the other settings are automatically loaded from the base [Engine.GameInfo] section.
If you're trying to load properties from a non-parent class, I don't think that is possible.

Change NamespaceManager on Full Text Search GAE

We have an application in GAE, and we are reenginering this to use Full Text. We have to index all data already in the GAE and our application also use namespaces.
We are trying to create a java procedure to be runned by administrator, who has not namespace. In other services, we have created similar java procedures, applying namespace by code, so the idea is to index all data in each namespace. (We use NamespaceFilter to control user domain.)
This is part of code:
private static final Index INDEX = SearchServiceFactory.getSearchService()
.getIndex(IndexSpec.newBuilder().setName("Actividad"));
NamespaceManager.set("userdomain1");
INDEX.add(doc);
Setting namespace is ignored.
Is this the expected behaviour? Is there an alternative way to index all the information in every namespace?
With similar code on datastore it's work fine.
A SearchService object is bound to a namespace, so you need to call NamespaceManager.set() before calling SearchServiceFactory.getSearchService(). Alternatively, call the version of getSearchService() that has a namespace parameter. See:
https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/search/SearchServiceFactory#getSearchService(java.lang.String)

Resources