In this sub-flow, how can I access from the http connector (red area) the inbound properties available at green marked area.
The scope of the inbound property is only just after the inbound endpoint or the source endpoint.
Here you should copy your inbound properties to the "flowVars" and then use it across the flow
#[flowVars.paramerterName = message.inboundProperties.'http.query.params'.parameterName]
Please make note if you want to access the HTTP properties, the syntax MEL format will be different for the Mule latest version and old version. The above one is valid for the latest Mule version and the syntax to access any property like below
#[message.inboundProperties.'http.query.params'.cityname]
where as in previous versions
#[message.inboundProperties['propertyName']].
This will depend on your inbound message source, but assuming it is an HTTP connector, use the MEL expression to access the inbound property http.query.params
#[message.inboundProperties['http.query.params']
The inbound message object is nothing but a HashMap of key-value pairs - best would be to use the debugger and select the keys you would like to access.
Here is the documentation for the Mule message, there you will find the description for the different kind of variables and properties. Inbound properties should be propagated from the main flow to the sub-flow and should still be available after the choice, excepting the case where you overwrite them or when there is an outbound-endpoint, which would overwrite them too.
Related
I have a line that reads like this in my flow:
<jms:inbound-endpoint queue="${queue.name}" connector-ref="${inbound.connector}" doc:name="Inbound Endpoint">
Where the "${inbound.connector}" property refers to a string in my properties file:
inbound.connector=Active_MQ
The reason I am doing this is because the connector-ref will vary depending on the environment. Sometimes it will be an Active_MQ connector, sometimes it will be a JMS Connector.
The properties file is under src/main/resources, as it should be. I have other properties in the flow that are read from the properties file just fine, such as the "queue.name" property. However, for some reason when I try to start Mule it is returning an error saying:
NoSuchBeanDefinitionException: No bean named '${inbound.connector}' is defined.
As far as I know the connector-ref value is just a string, so this should work in theory. I don't understand this error. Is the connector-ref in fact not a string, and this approach is illegal?
Internally mule runtime creates/initializes all the connector objects(spring bean) like HTTP Connectors, DATASOURCE connectors and various other connector's when the application comes up. All these connectors are nothing but a spring beans as Mule is written on top of Springframework. So it is not possible to make it dynamic by passing in a string value where it expects a object.
I have written a custom Anypoint connector (using devkit), and want it to set Inbound properties, much like the Mule HTTP connector does. MuleMessage however, does not seem to have facility to do this.
How does one mimic this behavior?
Inbound properties are immutable, It can be achieved via the MuleMessage https://www.mulesoft.org/docs/site/3.3.0/apidocs/org/mule/api/MuleMessage.html#setProperty(java.lang.String, java.lang.Object, org.mule.api.transport.PropertyScope)
However, unless your connector operation is a Message Source I wouldn't add inbound properties and instead use outbound properties.
You need to use
MuleMessage message = eventContext.getMessage();
message.setProperty("key","value",PropertyScope.INBOUND);
You can refer the API :-https://www.mulesoft.org/docs/site/3.3.0/apidocs/org/mule/api/MuleMessage.html#setProperty
https://www.mulesoft.org/docs/site/3.3.0/apidocs/org/mule/api/transport/PropertyScope.html
Is it possible to use mule message properties (like payload and flowvars) in a Mule Management Console notification body or subject?
I think it's not possible.
You can only use the properties exposed by mule, as explained here:
http://www.mulesoft.org/documentation/display/current/Defining+SLAs+and+Alerts#DefiningSLAsandAlerts-PropertiesUsedinAlertExpressions
Maybe using a Management Script, but there is no much info about it (the links to the javadoc are broken)
http://www.mulesoft.org/documentation/display/current/Scripting+Examples#ScriptingExamples-AlertingExamples
Yes you can use it. Mule provide various properties common to all alerts from class com.mulesoft.console.alert.RaisedAlert that can be used in defining the certain values such as
Flow identifier
Flow name
You may refer to mule documentation for it
https://docs.mulesoft.com/mule-management-console/v/3.7/defining-slas-and-alerts#DefiningSLAsandAlerts-PropertiesUsedinAlertExpressions
Let say I get a inbound variable from an http connector when I use this URL
http://x.x.x.x:8080/post?post-message=Hallo wold.
How can I use the value of the #[header:INBOUND:post-message] accross the complete flow from after the HTTP connector all the way up tp the end. Should I use the Mule Object store to write it to ram?
This post shows the scope of variables but it seem there is not one thay can flow from start to en like a session bean
https://m-square.com.au/mule-school-the-mulemessage-property-scopes-and-variables/
Kind Regards.
If you need the variable available throughout the whole flow (and
other flows reached through a flow-ref) use the invocation scope
(set-variable to set, flowVars[] to read it)
If you need it to reach other flows through a transport (e.g. VM) put
it in the outbound or session scope.
If you need it to live as long as the app is running, through
different calls, use the Mule registry (volatile, only available as
long as the app is up) or the object store (which can be configured
as persistent, to hold state even if the app goes down).
Mule Session variables are good enough to get the value throughout application.
But if you need to use the value outside your application, then you can set mule outbound properties.
There are three type of scope level variables supported by mule .
You can use flow variable if you want the variable to be accessible throughout the whole flow.
You can use session variable if you want it to be accessible form other flows through a transport barrier.
Refer this blog for getting better understanding of how different types of variables are propagated between different mule flows.
http://blogs.mulesoft.com/dev/anypoint-platform-dev/mule-school-the-mulemessage-property-scopes-and-variables/
How do i retrieve the values of MULE Headers like X-MULE_ROOT_MESSAGE_ID and X-MULE_SESSION. When I try to use them from #[message.inboundProperties[X-MULE_ROOT_MESSAGE_ID] I am not able to get values. How do I also get the client IP address from Mule HTTP inbound end point?
These X- headers are extracted and set directly as message properties or a session object.
So you'll find the content of X-MULE_ROOT_MESSAGE_ID by calling getMessageRootId() on the MuleMessage and you'll get the values serialized in X-MULE_SESSION directly in the current MuleSession object.
Read this How to correctly use Mule remote client address property to learn more about the remote IP address.
#[header:INBOUND:MULE_CORRELATION_ID]
you can get like this.
if you need to retrive in the java, you can get all the inbound as map (inbound properties) from message context.
Use Mule expressions to get the mule session id