I configured the following component:
<netsuite:search config-ref="Netsuite" searchRecord="EMPLOYEE" bodyFieldsOnly="false" returnSearchColumns="false" pageSize="10" doc:name="Netsuite">
<netsuite:criteria>
<netsuite:criterium key="isInactive">false</netsuite:criterium>
</netsuite:criteria>
</netsuite:search>
I am getting an error:
java.lang.IllegalArgumentException: Property isInactive in class class com.netsuite.webservices.lists.employees_2013_1.EmployeeSearch is not readable
I was able to find a solution for this. At first stage, we create a spring bean containing a search field value. Then use this bean in the NetSuite component. The correct flow is the following:
<spring:beans>
<spring:bean id="SearchBooleanField" name="SearchBooleanField" class="com.netsuite.webservices.platform.core_2013_1.SearchBooleanField" scope="prototype">
<spring:property name="searchValue" value="false"/>
</spring:bean>
</spring:beans>
...
<netsuite:search config-ref="Netsuite" searchRecord="EMPLOYEE_BASIC" bodyFieldsOnly="false" returnSearchColumns="false" pageSize="10" doc:name="Netsuite">
<netsuite:criteria>
<netsuite:criterium key="isInactive">#[app.registry.SearchBooleanField]</netsuite:criterium>
</netsuite:criteria>
</netsuite:search>
Related
<set-variable variableName="template" value="#[payload.templatePath]" doc:name="Template Path"/>
<custom-transformer class="com.comviva.mfs.eig.transformers.generic.MapUtil" doc:name="Map">
<spring:property name="sessionBean" ref="SessionBean"/>
<spring:property name="fixedTemplatePath" value="#[flowVars['template']]"/>
OR In both cases I want the value of the map to be replaced dynamically while sending the data as the key templatePath contains dynamic value and I want that to get picked from the payload that is of Map type
<custom-transformer class="com.comviva.mfs.eig.transformers.generic.MapUtil" doc:name="Map">
<spring:property name="sessionBean" ref="SessionBean"/>
<spring:property name="fixedTemplatePath" value="#[payload.templatePath]"/>
Spring properties are not interpreted by the MEL. As it is provided as setter injection which is invoked during instantiation the value of payload or a flow/session var will not be available.
You can change the transformer code to read the value from the payload within the transformation code itself as payload will be available from 'Object src' param.
I have multiple endpoints for different vendor's and we are differentiating it based on the userId for similar service operation and routing calls accordingly.
mule-app.properties
userIds=123,124,125
123.service.uri=http://google.com
124.service.url=http://yahoo.com
Can someone tell if there is a way to dynamically refer property using MEL and flowVariable holding userId value?
<flow name="test">
<http:listener config-ref="mylistenerconfig" path="test" doc:name="Request Listener" />
<set-variable variableName="userId" value="#[message.inboundProperties.userId]" />
<set-variable variableName="userServiceUri" value="${flowVars['userId'].service.uri}" />
<logger level="INFO" message="******* serviceUri=#[userServiceUri] ****" />
</flow>
I tried directly referring that value from message.inboundProperties.userId, referring it using a seperate variable - nothing works. Can someone suggest on how to achieve this?
Load the properties files with Spring:
<util:properties id="muleAppProps"
location="classpath*:mule-app.properties" />
Then you can dynamically refer to values in it with:
#[app.registry.muleAppProps[userId + '.service.uri']]
Assuming userId is a flow var that contains a value like "123"
I'm using Mule ESB CE 3.4. I have a requirement where I'm reading the configuration information from database and using it as the file name for the file outbound endpoint. Here is an example code (the code may not work as I have only given an outline)
<file:connector name="File-Data" autoDelete="false" streaming="true" validateConnections="true" doc:name="File" />
.....
<!-- Gets the configuration from database using a transformer. The transformer populates the configuration entries in a POJO and puts that in a session. -->
<custom-transformer class="com.test.DbGetConfigsTransformer" doc:name="Get Integration Configs"/>
....<!-- some code to process data -->
<logger message="$$$: #[sessionVars['currentFeed'].getFilePattern()]" doc:name="Set JSON File Name" /> -->
<file:outbound-endpoint path="/temp" outputPattern="#[sessionVars['currentFeed'].getFilePattern()]" responseTimeout="10000" mimeType="text/plain" connector-ref="File-Data" doc:name="Save File"/>
The above code throws the following error:
1. The filename, directory name, or volume label syntax is incorrect (java.io.IOException)
java.io.WinNTFileSystem:-2 (null)
2. Unable to create a canonical file for /temp/Test_User_#[function:datestamp:YYYYMMddhhmmss.sss] (org.mule.api.MuleRuntimeException)
org.mule.util.FileUtils:354 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MuleRuntimeException.html)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:///temp, connector=FileConnector
In the database table, the field name is called FilePattern and it has the value 'Test_User_#[function:datestamp:YYYYMMddhhmmss.sss]. If I hardcode the value or move this value to the mule configuration file
file.name=Test_User_#[function:datestamp:YYYYMMddhhmmss.sss]
and use the configuration property syntax (for e.g. ${file.name} in the 'outputpattern'), it works. But if I read the same from db and use it, it is not working and throwing the error. The logger displays as (which is read from the db)
$$$: Test_#[function:datestamp:YYYYMMddhhmmss.sss]
Any help is much appreciated.
If your datestamp format does not vary, you should just store the environment prefix in your db and use something like:
outputPattern="#[sessionVars['prefix']+server.dateTime.format('YYYYMMddhhmmss.sss')]"
If you need to use your current database values, you can use basic Java string methods to find the correct substrings. For example:
#[sessionVars['currentFeed'].getFilePattern().substring(0,sessionVars['currentFeed'].getFilePattern().indexOf('function')-2)+server.dateTime.format('YYYYMMddhhmmss.sss')]
If you use different datestamp formats, you can find that part as well using similar String methods. However, I still suggest you come up with an implementation that only stores the environment prefix in the db.
I am trying to use a download logger that should log any kind of file transfer between two end points as defined below in camel-context.xml
<process ref="downloadLogger"/>
<to uri="file:src/main/resources/META-INF?noop=true"/>
<!-- Prepare the message for calling OFBiz service -->
<setHeader headerName="Ofbiz.ServiceName">
<constant>DownLoadLogger</constant>
</setHeader>
<setHeader headerName="Ofbiz.Param.note">
<simple>${in.body}</simple>
</setHeader>
<!-- Call the OFBiz service -->
<camel:process ref="ofbizDispatcher"/>
</camel:route>
But this gives rise to
java.io.NotSerializableException: org.apache.camel.component.file.GenericFile
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1196)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:87)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:128)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.rmi.RmiProducer.process(RmiProducer.java:45)[camel-rmi-2.9.0.jar:2.9.0]
I am using jdk 1.6 camel 2.9 jar.
Please suggest if I am missing any configuration any where.
Thanks in advance
Padmalaya
Use following between 'from uri' and 'to uri'
<convertBodyTo type="byte[]"/>
I got this working after converting it to string, conversion to byte does not really work! :(
.convertBodyTo(String.class)
I've been having trouble with Camel transactions and after some great help from the camel list I eventually tracked it down to using org.apache.activemq.camel.component.ActiveMQComponent in a bean with id 'activemq'. If I use an id of 'activemqTx' it works. But I can't seem to find any documentation on the significance of 'activemqTx' as a bean id.
only one message gets through the route with this:
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
everything works with this:
<bean id="activemqTx" class="org.apache.activemq.camel.component.ActiveMQComponent">
Must have been a bean name clash