6

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

Mojtaba
  • 382
  • 1
  • 2
  • 26

1 Answers1

2

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.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Thank you, your comments are always helpful. but In this case I want to set other variables based on request path in order to route the requests, etc... , So set 'MULE_' properties and differentiate them doesn't resolve the issue here. Furthermore I think set and check properties may affect the performance in comparison with 'set-session-variable'. – Mojtaba May 26 '15 at 05:57
  • 1
    I wasn't suggesting to set `MULE_` properties but to read them to find a discriminant in them: you'd be free to compute a custom value based on this discriminant, and `set-session-variable` it. I do think reading/setting properties would have a significant performance impact, especially compared to the time that will be spent doing I/O. Don't decide against an approach based on potential perf issues: try load testing it to see the reality of it. – David Dossot May 26 '15 at 13:50