users@glassfish.java.net

Parallel processing of messages using MDB

From: Per Steffensen <steff_at_designware.dk>
Date: Tue, 31 Mar 2009 13:42:57 +0200

Hi

I am using Glassfish to run a MDB driven by a queue on ActiveMQ. I have
setup things so that my MDB is called with the message when I put a
message on the queue.

But if I put more than one message on the queue, they will not get
processed by Glassfish in parallel. They are processed one at the time.
I guess it is becaues I am not using connection pooling (to have more
than one connection to AcitveMQ?) og thread pooling to have more than
one thread to do the processing.

Well my goal is to get parallel processing of messages. Please help me how.

I am using the attached application (includes .java files), and my
server is setup using the attached setup script. Please notice that some
of the lines in setup is commented out, because I found out that they
were not necessary (and did not do anything for me???)

Please help me process messages in parallel.

Thanks, Per Steffensen


#!/bin/sh

# Make sure ActiveMQ is running

# Start Glassfish application server

# In Glassfish admin console (http://localhost:4848) add the following jars in Application Server | JVM Settings | Path Settings | Classpath suffix:
# <ActiveMQ install>/lib/activemq-core-XXX.jar
# <ActiveMQ install>/lib/commons-logging-YYY.jar

# Restart Glassfish application server

# From eclipse right-click on eMjavaee and select Export | EAR file, to have eMjavaee.ear file generated in EAR_BUILD_DEST/eMjavaee.jar (EAR_BUILD_DEST is you choice)

# Change the variables below and run this script to setup resources and deploy app

GLASSFISH_INSTALL=/Applications/Glassfish
EAR_BUILD_DEST=/Users/steffliace/Desktop
ACTIVEMQ_HOST=localhost
ACTIVEMQ_PORT=61616

$GLASSFISH_INSTALL/bin/asadmin undeploy eMjavaee
$GLASSFISH_INSTALL/bin/asadmin delete-admin-object jms/UserHandlerRQ
$GLASSFISH_INSTALL/bin/asadmin delete-connector-resource jms/ActiveMQQueueConnectionFactory
$GLASSFISH_INSTALL/bin/asadmin delete-connector-connection-pool ActiveMQQueueConnectionFactoryPool
$GLASSFISH_INSTALL/bin/asadmin delete-resource-adapter-config genericra
$GLASSFISH_INSTALL/bin/asadmin undeploy genericra

$GLASSFISH_INSTALL/bin/asadmin stop-domain domain1
$GLASSFISH_INSTALL/bin/asadmin start-domain domain1

$GLASSFISH_INSTALL/bin/asadmin deploy $GLASSFISH_INSTALL/lib/addons/resourceadapters/genericjmsra/genericra.rar
$GLASSFISH_INSTALL/bin/asadmin create-resource-adapter-config --property SupportsXA=true: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:LogLevel=FINE genericra
#$GLASSFISH_INSTALL/bin/asadmin create-connector-connection-pool --raname genericra --connectiondefinition javax.jms.QueueConnectionFactory --transactionsupport XATransaction ActiveMQQueueConnectionFactoryPool
#$GLASSFISH_INSTALL/bin/asadmin create-connector-resource --poolname ActiveMQQueueConnectionFactoryPool jms/ActiveMQQueueConnectionFactory
#$GLASSFISH_INSTALL/bin/asadmin create-admin-object --raname genericra --restype javax.jms.Queue --property DestinationProperties=PhysicalName\\='UserHandlerRQ' jms/UserHandlerRQ

$GLASSFISH_INSTALL/bin/asadmin stop-domain domain1
$GLASSFISH_INSTALL/bin/asadmin start-domain domain1

$GLASSFISH_INSTALL/bin/asadmin deploy --name eMjavaee $EAR_BUILD_DEST/eMjavaee.ear