Mojtaba
Mojtaba

Reputation: 382

Mule - How can I use set-session-variable in http:listener?

I have a composite-source consist of two http:listener in Mule;

I want to set a variable based on each of the listeners after receive requests from these listeners ;

but this error occurs while deploys in 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>

P.S. I have done it with http:inbound-endpoint

Upvotes: 6

Views: 676

Answers (1)

David Dossot
David Dossot

Reputation: 33413

It's illegal to put a set-session-variable there: the Mule schema does not allow it.

The reason is that http:listener is not a regular endpoint, like http:inbound-endpoint is, thus doesn't support this kind of nesting, like all other endpoints do.

This is unfortunate and hopefully something that will get fixed eventually. In the meantime, you need to find another way to discriminate requests coming between these two listeners.

For this I recommend you check all the inbound message properties they created, looking for a differentiator. I'm expecting a MULE_ property to be usable here but you'll have to check in your particular context, with the specific HTTP_Listener configurations you are using.

Upvotes: 2

Related Questions