I'm having difficulty with multiple HTTP connectors in a single project. What I'm trying to do may not be possible, but I'm wondering if there is some trick that will allow me to accomplish it.
As a starting point that works, I have a single connector with three flows: one handling the root URL and two other handling relative URLs. This works in that each address is returning the payload I expect...e.g., accessing the /flow3 relative path returns "Flow3".
<http:connector name="Connector1">
</http:connector>
<flow name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector1"/>
<set-payload value="Flow1"/>
</flow>
<flow name="Flow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector1" path="flow2"/>
<set-payload value="Flow2"/>
</flow>
<flow name="Flow3">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector1" path="flow3"/>
<set-payload value="Flow3"/>
</flow>
But, say I want to configure some endpoints one way and some endpoints another way...perhaps a different threading model...using connectors. I tried to do something like the following of adding another connector and having the third flow reference it:
<http:connector name="Connector1">
</http:connector>
<http:connector name="Connector2">
<!-- Eventually some different configuration here -->
</http:connector>
<flow name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector1"/>
<set-payload value="Flow1"/>
</flow>
<flow name="Flow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector1" path="flow2"/>
<set-payload value="Flow2"/>
</flow>
<flow name="Flow3">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8081" connector-ref="Connector2" path="flow3"/>
<set-payload value="Flow3"/>
</flow>
When I do this, Flow1 and Flow2 continue to work, but accessing /flow3 goes into Flow1 returning "Flow1". I'm assuming this is because the flow handling the root level URL on Connector1 indicates that it can handle this address.
I tried removing Flow1 to see what would happen. Flow2 continues to work but Flow3 now reports:
No receiver found with secondary lookup on connector: Connector1 with URI key: http://localhost:8081/flow3
(I'm wondering if this is the favicon request causing a problem, but am not sure.)
Is doing something like this...i.e., having two connectors in the same project but using one of them explicitly for a relative URL...possible?
The problem is that the each endpoints creates its own message receiver.In general that is not a problem but when it comes to TCP based transport they will compete for ports.
If you look at the log, before the startup splash scree you will see the following error:
Root Exception stack trace:
java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
+ 3 more (set debug level logging or '-Dmule.verbose.exception
and that means that the inbound endpoint for Flow3 can not bind the port 8081 because a socket for already own that port and that socket belongs to the Connector1