Performance and Tuning

      

Tuning Message-Driven Beans

The following sections provide tuning and best practice information for Message-Driven Beans (MDBs):

 


Use Transaction Batching

MDB transaction batching allows several JMS messages to be processed in one container managed transaction. Batching amortizes the cost of transactions over multiple messages and when used appropriately, can reduce or even eliminate the throughput difference between 2PC and 1PC processing. See Transaction Batching of MDBs in Programming WebLogic Enterprise JavaBeans.

Notes:

 


MDB Thread Management

Thread management for MDBs is described in terms of concurrency—the number of MDB instances that can be active at the same time. The following sections provide information on MDB concurrency:

 

Determining the Number of Concurrent MDBs

Table 10-1 provides information on how to determine the of concurrently running MDB instances for a server instance.

Table 10-1 Determining Concurrency for WebLogic Server MDBs
Type of work manager or execute queue Threads
Default work manager or unconstrained work manager varies due to self-tuning, up to Min(max-beans-in-free-pool,16)
Default work manager with self-tuning disabled Min(default-thread-pool-size/2+1, max-beans-in-free-pool)

This is also the default thread pool concurrency algorithm for WebLogic Server 8.1

Custom execute queue Min(execute-queue-size, max-beans-in-free-pool) Custom work manager with constraint varies due to self-tuning, between min-thread-constraint and Min(max-threads-constraint, max-beans-in-free-pool)

Transactional WebLogic MDBs use a synchronous polling mechanism to retrieve messages from JMS destinations if they are either: A) listening to non-WebLogic queues; or B) listening to a WebLogic queue and transaction batching is enabled. See Token-based Message Polling for Transactional MDBs Listening on Queues.

 

Selecting a Concurrency Strategy

The following section provides general information on selecting a concurrency strategy for your applications:

Every application is unique, select a concurrency strategy based on how your application performs in its environment.

 

Thread Utilization When Using WebLogic Destinations

The following section provides information on how threads are allocated when WebLogic Server interoperates with WebLogic destinations.

For information on how threads are allocated when WebLogic Server interoperates with foreign vendor MDBs, see Thread Utilization When Using Foreign MDBs.

 


Using Foreign Vendor MDBs

The following sections provide information on the behavior of WebLogic Server when using foreign vendor MDBs:

 

Determining Concurrency for Foreign MDBs

When using foreign MDBs, WebLogic Server determines concurrency as shown in Table 10-2.

Table 10-2 Determining Concurrency for Foreign Vendor MDBs
Tuning Factor Information Reference
Queue Same algorithm as for WebLogic MDBs
Topic: Non-transactional Concurrency is always one.
Topic: Transactional Same algorithm as for WebLogic MDBs.

 

Thread Utilization When Using Foreign MDBs

The following section provides information on how threads are allocated when WebLogic Server interoperates with foreign vendor MDBs:

Token-based Message Polling for Transactional MDBs Listening on Queues

Transactional WebLogic MDBs use a synchronous polling mechanism to retrieve messages from JMS destinations if they are either: A) listening to non-WebLogic queues; or B) listening to a WebLogic queue and transaction batching is enabled. With synchronous polling, one or more WebLogic polling threads synchronously receive messages from the MDB's source destination and then invoke the MDB application's onMessage callback.

As of WebLogic 10.3, the polling mechanism changed to a token-based approach to provide better control of the concurrent poller thread count under changing message loads. In previous releases, the thread count ramp-up could be too gradual in certain use cases. Additionally, child pollers, once awoken, could not be ramped down and returned back to the pool for certain foreign JMS providers.

When a thread is returned to the thread pool with token-based polling, the thread's internal JMS consumer is closed rather than cached. This assures that messages will not be implicitly pre-fetched by certain foreign JMS Providers while there is no polling thread servicing the consumer.

In addition, each MDB maintains a single token that provides permission for a given poller thread to create another thread.

Backwards Compatibility for WLS 10.0 and Earlier-style Polling

In WLS 10.0 and earlier, transactional MDBs with batching enabled created a dedicated polling thread for each deployed MDB. This polling thread was not allocated from the pool specified by dispatch-policy, it was an entirely new thread in addition to the all other threads running on the system. See Use Transaction Batching.

To override the token-based polling behavior and implement the WLS 10.0 and earlier behavior, you can either:

When using foreign transactional MDBs with the WLS 8.1-style polling flag, some foreign vendors require a permanently allocated thread per concurrent MDB instance. These threads are drawn from the pool specified by dispatch-policy and are not returned to the pool until the MDB is undeployed. Since these threads are not shared, the MDB can starve other resources in the same pool. In this situation, you may need to increase the number of threads in the pool.

Note: With the token-based polling approach for such foreign vendors, the thread's internal JMS message consumer is closed rather than cached to assure that messages will not be reserved by the destination for the specific consumer.