Mule - How can I use set-session variable in http: listener?
I have composite-source
two http:listener
in Mule;
I want to set a variable based on each of the listeners after receiving requests from those listeners;
but this error occurs when deploying to mule 3.6.0:
org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'set-session-variable'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/http":response-builder, "http://www.mulesoft.org/schema/mule/http":error-response-builder}' is expected.
What should I do?
Here is my code:
<composite-source doc:name="Composite Source">
<http:listener config-ref="HTTP_Listener_Configuration_Source1"
path="/" doc:name="HTTP">
<set-session-variable doc:name="Session Variable" value="#[x]" variableName="x" />
</http:listener>
<http:listener config-ref="HTTP_Listener_Configuration_Source2"
path="/" doc:name="HTTP">
<set-session-variable doc:name="Session Variable" value="#[y]" variableName="x" />
</http:listener>
</composite-source>
PS I did it with http:inbound-endpoint
source to share
Wrong to put there set-session-variable
: Mule's schema doesn't allow it.
The reason is that http:listener
it is not regular endpoint
, like http:inbound-endpoint
is, so it does not support this type of nesting like all other endpoints.
This is unfortunate and hopefully something that will eventually get fixed. In the meantime, you need to find another way to distinguish between the requests coming in between these two listeners.
To do this, I recommend that you check all the properties of the incoming messages they have created looking for the distinguishing feature. I expect a property to be used here MULE_
, but you will need to check your specific context with the specific configurations HTTP_Listener
you are using.
source to share