users@glassfish.java.net

More than one instance of a MDB

From: Per Steffensen <steff_at_designware.dk>
Date: Fri, 22 Jan 2010 21:41:15 +0100

Hi

I am making an application with a MDB (MyMDB). I do not get any parallel
processing in my MDB. If there is more than one message on the driving
queue, message #2 will not be delivered to the MDB before handling of
message #1 finished. It is like there is only one instance (or maybe
only one thread) of the MDB to handle messages. What can I do to make
more instances/threads run in parallel?

Regards, Per Steffensen

--------------------- My setup ------------------------------

Glassfish v2.1
ActiveMQ 5.2.0 (persisted in MySQL database)

Config of Glassfish:
* asadmin create-resource-adapter-config --property
SupportsXA=false:RMPolicy=OnePerPhysicalConnection:ProviderIntegrationMode=javabean:ConnectionFactoryClassName=org.apache.activemq.ActiveMQConnectionFactory:QueueConnectionFactoryClassName=org.apache.activemq.ActiveMQConnectionFactory:TopicConnectionFactoryClassName=org.apache.activemq.ActiveMQConnectionFactory:XAConnectionFactoryClassName=org.apache.activemq.ActiveMQXAConnectionFactory:XAQueueConnectionFactoryClassName=org.apache.activemq.ActiveMQXAConnectionFactory:XATopicConnectionFactoryClassName=org.apache.activemq.ActiveMQXAConnectionFactory:UnifiedDestinationClassName=org.apache.activemq.command.ActiveMQDestination:QueueClassName=org.apache.activemq.command.ActiveMQQueue:TopicClassName=org.apache.activemq.command.ActiveMQTopic:ConnectionFactoryProperties=brokerURL\\=tcp\\://$ACTIVEMQ_HOST\\:$ACTIVEMQ_PORT?wireFormat.maxInactivityDuration\\=0:LogLevel=FINE
genericra
* asadmin create-connector-connection-pool --raname genericra
--connectiondefinition javax.jms.ConnectionFactory --transactionsupport
LocalTransaction MessageQueueConnectionFactoryPool
* asadmin set
domain.resources.connector-connection-pool.MessageQueueConnectionFactoryPool.connection-creation-retry-attempts=2
* asadmin create-connector-resource --poolname
MessageQueueConnectionFactoryPool jms/MessageQueueConnectionFactory

MyMDB.java:
@TransactionManagement(TransactionManagementType.BEAN)
@MessageDriven(name = "MyMDB")
public class MyMDB implements MessageListener {
...
}

sun-ejb-jar.xml:
<sun-ejb-jar>
 <enterprise-beans>
   <unique-id>1</unique-id>
   <ejb>
     <ejb-name>MyMDB</ejb-name>
     <mdb-resource-adapter>
       <resource-adapter-mid>genericra</resource-adapter-mid>
       <activation-config>
        <activation-config-property>
          
<activation-config-property-name>DestinationType</activation-config-property-name>
          
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          
<activation-config-property-name>DestinationProperties</activation-config-property-name>
          <activation-config-property-value>PhysicalName=My
RQ</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>MaxPoolSize</activation-config-property-name>
         
<activation-config-property-value>32</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>RedeliveryAttempts</activation-config-property-name>
         
<activation-config-property-value>0</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>ReconnectAttempts</activation-config-property-name>
         
<activation-config-property-value>4</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>ReconnectInterval</activation-config-property-name>
         
<activation-config-property-value>10</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>RedeliveryInterval</activation-config-property-name>
         
<activation-config-property-value>1</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
         
<activation-config-property-name>SendBadMessagesToDMD</activation-config-property-name>
         
<activation-config-property-value>false</activation-config-property-value>
       </activation-config-property>
      </activation-config>
     </mdb-resource-adapter>
   </ejb>
 </enterprise-beans>
</sun-ejb-jar>