I know how to set property using property mediator but don't know how to use remove property using property mediator. Can anyone give me an example?
See https://docs.wso2.com/display/ESB490/Generic+Properties
Sample : <property name="TRANSPORT_HEADERS" action="remove" scope="axis2"/>
Related
I would like to know if it is possible to push property in the cache hazelcast.
I work with a distributed environment and would like properties to be shared across all environments. Is it possible?
My current configuration for loading properties is as follows:
<bean id="propertiesConfigurer" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="systemPropertiesMode" value="2"/>
<property name="properties" ref="allProperties" />
</bean>
Thank you
You can simply use the distributed data structures of Hazelcast (i.e. IMap) and put any data you want as long as you make them serializable.
Yes, you can create a distributed map with entries as <String, Properties>. Each entry will keep a set of properties. Or, you can create a simple distributed map with entries as <String, String> and use this map as a set of properties.
I have the following context configuration:
<bean id="propertiesFactory" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:conf.properties</value>
</list>
</property>
</bean>
<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="properties" ref="propertiesFactory"/>
</bean>
<bean id="messageThrottlerHolder" class="foo.bar.common.MessageThrottlerHolder"/>
<bean id="cassandraRoute" class="foo.bar.routes.CassandraRouteBuilder"/>
Then in both classes: MessageThrottlerHolder and in CassandraRouteBuilder there is:
#BeanInject
Properties properties;
Wonderful.
But CassandraRouteBuilder may/could use properties without NPE, as properties are well initialized.
On the other hand the MessageThrottlerHolder is not able to use properties as in the constructor properties are null and there is no way to initialize them.
How can I check why properties are null?
What can be wrong, that #BeanInject somehow does not initialize properties?
You are doing this wrong if you think that Properties are somehow Camel property placeholder or anything like that.
Camel's #BeanInject is for looking up bean in the Camel register via a bean name/id, as a poor-mans Spring IoC. If you are using Spring then you can use the Spring #Autowired or whatever they have for that.
If you want to access properties from the properties placeholder, then you can inject CamelContext and use its API for resolving: http://static.javadoc.io/org.apache.camel/camel-core/2.20.0/org/apache/camel/CamelContext.html#resolvePropertyPlaceholders-java.lang.String-
Or use Camel's #PropertyInject instead where you specify the key name to lookup. I am not sure if Spring has any similar annotation for looking up properties, as you have turned on the camel-spring bridge. You can also try to look into that.
I have a properties file shared on several apps. To access this properties into one app, I use this tag:
<context:property-placeholder location="classpath:br/com/empresa/configuracao/mule-apps.properties"/>
On several Mule components, like database attributes connections, I use the following expression to access the properties, p.e.: ${db.user}. It works!
But on Java Transformer, how I access the properties?
I tried the following instructions, but returned null:
System.getProperty("db.user");
message.getInboundProperty("db.user");
message.getOutboundProperty("db.user");
message.getInvocationProperty("db.user");
Is there a way to access properties into Mule Java Transformer?
This question has been answered for components here: How to get property from context property placeholder tag inside custom java component The exact same logic applies to transformers.
Use property injection:
<custom-transformer class="org.myCompany.CustomTransformer">
<property name="dbUser" value="${db.user}" />
</custom-transformer>
Don't forget to add setDbUser on your custom component!
You could use the old way of retrieving a property:
#Value("${db.user")
private String dbUser;
I need to set the global property grammatically. Functionally it should do exactly what the following statement should be doing
<global-property name="host-name" value="localhost" doc:name="Global Property"/>
I believe I should be able to access this property using ${host-name}. In this specific scenarion I don't want to load the property from properties file.
If you just want to resolve placeholders like ${host-name} you can extend the Spring PropertyPlaceholderConfigurer class with a custom implementation of method resolvePlaceholder, and add it as a Spring bean like this:
<spring:beans>
<spring:bean id="myConfigurer" class="my.test.MyConfigurer"/>
</spring:beans>
Your custom resolvePlaceholder is then called to resolve any unresolved properties.
It is also fairly simple to set actually set properties in the Mule context registry by getting the context from a message (message.getMuleContext()) or by implementing a MuleContextAware bean, but in those cases the property will not yet be available at the time when the property placeholders are resolved.
You would set the property like this:
context.getRegistry().registerObject("myKey", "myVal")
and access it later like this:
context.getRegistry().get("myKey")
What is a standart way of passing properties to a custom action without parsing them? I mean if I write "X1=X1value X2=X2value", then in my custom action X1 will be equal to "X1value X2=X2value", and X2 won't exist as a separate property. So what is the properties string format?
I don't know that there is a "standard" for serializing and serializng CustomActionData. There are a couple libraries out there though. If you happen to be using C# DTF custom actions there is a CustomActionData class that can serialize and deserialize the property collection for you. Otherwise you pretty much come up with your own pattern like:
/PROPERTYA=VALUEA /PROPERTYB=VALUEB
or
PROPERTYA=VALUEA;PROPERTYB=VALUEB
Or even an XML fragment like
<Properties>
<Property Id="PROPERTYA">VALUEA</Property>
<Property Id="PROPERTYB">VALUEB</Property>
</Properties>
The point is to serialize and deserialize so that it can be available to your deferred CA.