Mule threading profile & processing strategy

14
Mule Threading Management •SEDA •Thread pools •Tuning Threading Profile •Processing Strategy •Async scope

Transcript of Mule threading profile & processing strategy

Page 1: Mule threading profile & processing strategy

Mule Threading Management• SEDA• Thread pools• Tuning Threading Profile• Processing Strategy• Async scope

Page 2: Mule threading profile & processing strategy

SEDA(staged event-driven architecture)• decomposes a complex, event-driven application into a set of stages

connected by queues

Page 3: Mule threading profile & processing strategy
Page 4: Mule threading profile & processing strategy

Factors that determine Thread Pool • Configured exchange pattern• Outbound message processor• Transaction• Processing strategy

Page 5: Mule threading profile & processing strategy

If you are using synchronous processing, the same thread is used to carry the message all the way through Mule. As the message is processed, if it needs to be sent to an outbound endpoint, one of the following applies:• If the outbound endpoint is one-way, the message is sent using the same

thread. Once it has been sent, the thread resumes processing the same message. It does not wait for the message to be received by the remote endpoint.• If the outbound endpoint is request-response, the flow thread sends the

message to the outbound endpoint and waits for the response. When the response arrives, the flow threads resumes by processing the response.

Page 6: Mule threading profile & processing strategy

If you are doing asynchronous processing, the receiver thread is used only to place the message on a staged event-driven architectur (SEDA) queue, at which point the message is transferred to a flow thread, and the receiver thread is released back into the receiver thread pool so it can carry another message. As the message is processed, if it needs to be sent to an outbound endpoint, one of the following applies:• If the outbound endpoint is one-way, the message is copied and the copy

processed by a dispatcher thread, while the flow thread continues processing the original message in parallel.• If the outbound endpoint is request-response, the flow thread sends the

message to the outbound endpoint and waits for the response. When the response arrives, the flow threads resumes by processing the response.

Page 7: Mule threading profile & processing strategy

Scenario 1-Fully SEDA architecture• Inbound connector is one-way• Outbound connector is one-way• No transactional flow

Page 8: Mule threading profile & processing strategy

Scenario 2- synchronous-asynchronous mode• Receiver Thread is exchange-pattern• Dispacher Thread is one-way

Page 9: Mule threading profile & processing strategy

Scenario 3- Fully synchronous mode

Page 10: Mule threading profile & processing strategy

Scenario 4 - asynchronous-synchronous mode

Page 11: Mule threading profile & processing strategy

How to implement own SEDA• Mule’s VM transport is an excellent mechanism to help break your

flows into smaller, composite flows that are decoupled with in-memory queueing. This allows you to realize the benefits of SEDA at the macro level, breaking your application into smaller flows that can be individually tuned and are decoupled with VM queueing.

Page 12: Mule threading profile & processing strategy

Tuning threading profile• Configuration level• Connector level• Flow level

Page 13: Mule threading profile & processing strategy

Default Threading profile• <configuration>• <default-threading-profile• maxBufferSize="100" maxThreadsActive="20"• maxThreadsIdle="10" threadTTL="60000"• poolExhaustedAction="ABORT" />• </configuration>

Page 14: Mule threading profile & processing strategy

Processing Strategy• default queued asynchronous • Synchronous-thread-per-processor-processing-strategy• queued-thread-per-processor-processing-strategy• thread-per-processor-processing-strategy (with cores)