Tad
Tad

Reputation: 517

Controlling number of threads in Mule

I'm using Mule 3.3.1 Community Edition.

I have a flow that accepts HTTP requests. This runs successfully.

<flow name="TestFlow">
    <http:inbound-endpoint exchange-pattern="request-response" 
        host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
        encoding="UTF-8"/>
    <logger level="INFO" category="hello" doc:name="Logger"/>
</flow>

The service needs to be single-threaded so that messages are handled strictly in the order in which they are received. My thought was to set maxThreadsActive=1 and maxBufferSize=100 to get my desired behavior. However, I can't get any control over threads to work.

At this point I'm just trying to get a thread profile working, regardless of the number of threads. I added a threading-profile exactly out of the current version of the Manning book Mule in Action, but Mule rejects it as "Invalid content" and won't run.

<flow name="TestFlow">
    <threading-profile maxBufferSize="100" maxThreadsActive="20" maxThreadsIdle="10"
        threadTTL="60000" poolExhaustedAction="RUN" />

    <http:inbound-endpoint exchange-pattern="request-response" 
        host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
        encoding="UTF-8"/>
    <logger level="INFO" category="hello" doc:name="Logger"/>
</flow>

I commented that out and moved up to a configuration block.

<configuration>
    <default-threading-profile maxThreadsActive="20" maxBufferSize="100" 
         poolExhaustedAction="RUN" />
</configuration>

<flow name="TestFlow">
    <http:inbound-endpoint exchange-pattern="request-response" 
        host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
        encoding="UTF-8"/>
    <logger level="INFO" category="hello" doc:name="Logger"/>
</flow> 

Mule accepts this, but the service no longer returns; the client simply hangs waiting for a response.

How do I configure my flow so that I can control thread pool size and, once that's done, so that only one thread is available in the pool?

Upvotes: 3

Views: 9746

Answers (1)

David Dossot
David Dossot

Reputation: 33413

You need to configure the receiver-threading-profile of the HTTP connector:

<http:connector name="httpConnector">
  <receiver-threading-profile maxThreadsActive="1" />
</http:connector>

Upvotes: 3

Related Questions