I have a property defined in properties file.Note client1 prefix, which is calculated dynamically when request hits.
client1_appilicationid=OBCDSEFT
i have 2 variables defined in my flow;
<set-variable value="#[attributes.headers.'x-client-id']" doc:name="ClientId" doc:id="1e33f179" variableName="clientid"/>
Here attributes.headers.'x-client-id' =client1
<set-variable value="'#[vars.clientid]'++'_'++'applicationid'" doc:name="applicationId" doc:id="9df0420e" variableName="applicationid"/>
In the above if i access #[vars.applicationd] it will print client1_appilicationid as value. but i want 'OBCDSEFT' as value. How I can define applicationId variable to get that?
You are just concatenating the client id header value with the suffix, however that will not read a property value. You should use the p() function to read properties values.
The expression should be something like this: #[p(vars.clientid++'_'++'applicationid')]
Related
Can I find a process instance by a process instance variable value via the Camunda REST API as described in this request:
https://groups.google.com/forum/#!topic/camunda-bpm-dev/gJfXkbkY8fc
(the question above is from 2014, maybe there is a standard way now?)
Looks like this is supported now:
GET /process-instance
variables: Only include process instances that have variables with certain values. Variable filtering expressions are comma-separated and are structured as follows:
A valid parameter value has the form key_operator_value. key is the variable name, operator is the comparison operator to be used and value the variable value.
There is also a POST endpoint which allows to express the filtering more cleanly:
POST /process-instance
variables: A JSON array to only include process instances that have variables with certain values.
The array consists of objects with the three properties name, operator and value. name (String) is the variable name, operator (String) is the comparison operator to be used and value the variable value.
I have a payload as list of maps and another flow variable as map.
I wanted to add flow variable to payload list. I tried using this expression #[payload.addAll(flowVars['entitlement'])]in expression component. But it sets the payload to boolean value true.
Use expression component like
<expression-component doc:name="Expression"><![CDATA[payload.addAll(flowVars['entitlement'])]]></expression-component>
Hope this helps.
Try using Set Payload transformer.
and add
[payload.addAll(flowVars['entitlement']) as value.
You set the payload as the value returned by addAll(). It's like doing payload = payload.addAll(flowVars['entitlement']) in Java addAll() returns a boolean, that's why your payload becomes true.
You can use instead:
#[payload.addAll(flowVars['entitlement']); payload)
This will perform your addAll() operation on your payload and then return this modified payload afterward. ; allow your to perform multiple expressions in MEL
You can use dataweave transform component and add the elements in various ways like using the ++ operator or use map operator to change the structure as per your requirements.
I've added a User Defined Variables element
Then created a variable ${Parameter} with value "123456" and passed it in a GET request.
Created a second variable ${Response} with value "Invalid code 123456"
I've added a Response Assertion element
Added the ${Response} variable to the Response Assertion
When I send the request like this, everything is fine. But if I add the second variable in the value field, then an Assertion error is returned.
What I'm trying to do is to add a variable to the value field of an already existing variable:
e.g. Set the Value of the ${Response} variable as "Invalid code ${Parameter}"
How can I achieve this in jmeter?
Why are you unnecessarily making the things complex!
You can directly use the value you want to assert in the Response Assertion.
Keep as follows:
Invalid code ${Parameter}
Here, ${Parameter} value be evaluated first and checked against the response.
Just incase, if you want to use JMeter variable as value to another JMeter variable, use as follows, using ${__evalVar()}:
Invalid code ${__evalVar(Parameter)}
Note: observed that if you define both the variables in the same UDV, Parameter value is empty. So, add two UDVs and define Parameter in the first UDV and Response in the second UDV with above value.
I want to extract my payload's class name in a MUnit assert so I can verify the payload is always of the correct type. I've tried 2 MEL expressions, but both return null in the MEL expression evaluator. The funny thing is that if I remove the .name part of the expression then I see a key called "name" with the value that I need. Any ideas?
payload.class.name
message.dataType.type.name
One way is: #[payload.getClass().getSimpleName()]
From this SO question Mule expression variable scope, I understood that:
variables declared using set-payload are like instance variables.
variables defined in expression component are like method local variables.
Is my understanding correct? How do we access variables inside expression component?
There is something wrong in your question..
You cannot declare a variable using set-payload... set-payload are used to override existing message payload ..
You can set variable using <set-variable>
Now back to your question ..
Yes there are 2 types of variable in Mule :-
Flow Variables
Session Variables
If you use Flow variable, it is an instance variable.. the scope of the variable is INVOCATION .. that is limited to a particular Flow (and sub-flow)
where as if you use Session Variables .. It's scope is Global and can access from any flow in the configuration
So now .. as I said you can declare a variable using <set-variable> .. here during declaring the variable you need to declare it's scope ... That is either INVOCATION or SESSION
Similarly if you declare a variable using expression component you need to declare the variable either as INVOCATION or SESSION
for example .. see the following :-
<set-session-variable variableName="sessionId" value="#[message.id+’#’+mule.nodeId]" />
<expression-component>sessionVars.sessionId = message.id+'#'+mule.nodeId;</expression-component>
Here you are setting variable using both <set-variable> and Expression Component
and you are setting here as a Global or you can say as a Session Variable
Please find the following for your reference :-
http://blogs.mulesoft.org/mule-school-the-mulemessage-property-scopes-and-variables/
UPDATED ANSWER:-
Yes .You can set the variable either in set-variable or expression and you can access the variable anywhere and it doesn't matter where you have declared ..
For example if you want access the session variables in Expression component that you have declared in set-session-variable using the following :- <set-session-variable variableName="sessionId" value="#[message.id+’#’+mule.nodeId]" /> .....
you can do the following :-
set the session variable into payload <expression-component>payload=sessionVars.sessionId;</expression-component>
and then you can print payload using logger :-
<logger message="payload with sessionVars:-#[message.payload]" level="INFO" doc:name="Logger"/>
to check the value