<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" 
         xmlns="http://docbook.org/ns/docbook" 
         xmlns:xlink="http://www.w3.org/1999/xlink" 
         xmlns:xi="http://www.w3.org/2001/XInclude" 
         xmlns:svg="http://www.w3.org/2000/svg" 
         xmlns:mml="http://www.w3.org/1998/Math/MathML" 
         xmlns:html="http://www.w3.org/1999/xhtml" 
         xmlns:db="http://docbook.org/ns/docbook" 
         xml:lang="en" 
         xml:id="ejb2.mdb_tuning">

  <info><title>Tuning Message-driven Bean Pool</title></info>
  <para>
     A pool is handled by JOnAS for each Message-driven bean. The pool can be configured in the JOnAS-specific deployment descriptor with the following tags:  </para>
    <section><info><title>min-pool-size</title></info>
       <para>
       This optional integer value represents the minimum instances that will be created in the pool when the bean is loaded. This will improve bean instance creation time, at least for the first beans. The default value is 0.  </para>
    </section>
    <section><info><title>max-cache-size</title></info>
      <para>
       This optional integer value represents the maximum number of instances of 
      ServerSession
       that may be created in memory. The purpose of this value is to keep JOnAS scalable. The policy is the following: 
       When the 
      ConnectionConsumer
       ask for a 
      ServerSession
       instance (in order to deliver a new message) JOnAS tries to give an instance from  the 
      ServerSessionPool
      . If the pool is empty, a new instance is created only if the number of yet created instances is smaller  than the max-cache-size parameter. When the max-cache-size is reached, the 
      ConnectionConsumer
       is blocked and it cannot deliver new messages until a 
      ServerSession
       is eventually returned in the pool. A 
      ServerSession
       is pushed into the pool at the end of the 
      onMessage
       method.
       The default value is no limit (this means that a new instance of 
      ServerSession
       is always created when the pool is empty). </para>
      <para>
         The values for 
        <code>
          max-cache-size
        </code>
         should be set accordingly to 
        <code>
          jonas.service.ejb.maxworkthreads
        </code>
         value. See 
        <link xlink:href="configuration_guide.html#N10D43">
          Configuring JMS Service
        </link>
        . 
      </para>
    </section>
    <section><info><title>example</title></info>
      
      <screen>
  &lt;jonas-ejb-jar&gt;
    &lt;jonas-message-driven&gt;
      &lt;ejb-name&gt;Mdb&lt;/ejb-name&gt;
      &lt;jndi-name&gt;mdbTopic&lt;/jndi-name&gt;
      &lt;max-cache-size&gt;20&lt;/max-cache-size&gt;
      &lt;min-pool-size&gt;10&lt;/min-pool-size&gt;
    &lt;/jonas-message-driven&gt;
  &lt;/jonas-ejb-jar&gt;
   
      </screen>
    </section>
  </section>