Skip to main content

What decides when to process messages with MDB

3 replies [Last post]
steff1193
Offline
Joined: 2009-03-24
Points: 0

Hi

We have a system where MDBs in a JEE application deployed in Glassfish
v2.1.1 process messages on ActiveMQ v5.4.2-fuse-02-00 queues. In an
test-setup a test-driver generates a lot of messages on the queues in
ActiveMQ, so there is always "enough" messages to work with for the
MDB's. Despite that it does not seem that all MDB-instances as working
all the time. A lot of other stuff is going on on the system at the same
time so the system is under a certain amount of load, and that might be
a parameter in the "algoritm" deciding how many messages should be
processed concurrently by MDB's?
But basically I would like to know details about the "alogritm" that
decides when and how many messages are processed by MDB's concurrently.
A concrete question is why I experience, when you keep in mind that
there are plenty of messages to work with, that most of the time not
even 16 (stady-pool-size) msgs are processed at the same time? I believe
that there are always "enough" threads in the MDB-driving thread-pool
(mdb-threadpool - see below).

A little more details about our setup:
- We have set up a threadpool for MDB processing:
$GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-threadpool
--minthreadpoolsize 0 --maxthreadpoolsize 100 --idletimeout 120
--workqueues 1 mdb-threadpool
- We are using the resource-adapter that comes with ActiveMQ:
$GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME deploy --name activemqra
./fixed-config/glassfish/activemq-rar-5.4.2-fuse-02-00.rar
$GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
create-resource-adapter-config --threadpools mdb-threadpool --property
ServerUrl=tcp\\://$ACTIVEMQ_HOST\\:$ACTIVEMQ_PORT activemqra
- We also use the resource-adapter to create a pool of connection to
ActiveMQ (a.o. used by other processen in the Glassfish application to
put new messages on ActiveMQ queues)
$GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
create-connector-connection-pool --raname activemqra
--connectiondefinition javax.jms.ConnectionFactory --transactionsupport
XATransaction MessageQueueXAConnectionFactoryPool
$GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-connector-resource
--poolname MessageQueueXAConnectionFactoryPool
jms/MessageQueueXAConnectionFactory
- MDB's are annotated like this:
@MessageDriven(name = "MyMDB")
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
- sun-ejb-jar.xml has the following configuration-fragments for each MDB:

MyMDB

16
2
32

activemqra

destinationType

javax.jms.Queue

destination

MyWPQ

maximumRedeliveries

0

maxMessagesPerSessions

100

maxSessions

10

- Let me know if you need more info about our setup

Regards, Per Steffensen

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jagadish Prasat...
Offline
Joined: 2011-03-11
Points: 0

Submission of work is done by the resource-adapter which might also be a
factor.

You can :
1) get a jstack to see how many threads from the mdb-thread-pool are in
use
2) try enabling monitoring statistics of work-manager and thread-pools :
http://download.oracle.com/docs/cd/E19879-01/820-4335/6nfqc3qp8/index.html
http://download.oracle.com/docs/cd/E19879-01/820-4335/ablvi/index.html
http://download.oracle.com/docs/cd/E19879-01/820-4335/ablvk/index.html

which might give some clues.

--
Thanks,
-Jagadish

On Wed, 2011-06-15 at 14:32 +0200, Per Steffensen wrote:
> Hi
>
> We have a system where MDBs in a JEE application deployed in Glassfish
> v2.1.1 process messages on ActiveMQ v5.4.2-fuse-02-00 queues. In an
> test-setup a test-driver generates a lot of messages on the queues in
> ActiveMQ, so there is always "enough" messages to work with for the
> MDB's. Despite that it does not seem that all MDB-instances as working
> all the time. A lot of other stuff is going on on the system at the same
> time so the system is under a certain amount of load, and that might be
> a parameter in the "algoritm" deciding how many messages should be
> processed concurrently by MDB's?
> But basically I would like to know details about the "alogritm" that
> decides when and how many messages are processed by MDB's concurrently.
> A concrete question is why I experience, when you keep in mind that
> there are plenty of messages to work with, that most of the time not
> even 16 (stady-pool-size) msgs are processed at the same time? I believe
> that there are always "enough" threads in the MDB-driving thread-pool
> (mdb-threadpool - see below).
>
> A little more details about our setup:
> - We have set up a threadpool for MDB processing:
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-threadpool
> --minthreadpoolsize 0 --maxthreadpoolsize 100 --idletimeout 120
> --workqueues 1 mdb-threadpool
> - We are using the resource-adapter that comes with ActiveMQ:
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME deploy --name activemqra
> ./fixed-config/glassfish/activemq-rar-5.4.2-fuse-02-00.rar
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
> create-resource-adapter-config --threadpools mdb-threadpool --property
> ServerUrl=tcp\\://$ACTIVEMQ_HOST\\:$ACTIVEMQ_PORT activemqra
> - We also use the resource-adapter to create a pool of connection to
> ActiveMQ (a.o. used by other processen in the Glassfish application to
> put new messages on ActiveMQ queues)
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
> create-connector-connection-pool --raname activemqra
> --connectiondefinition javax.jms.ConnectionFactory --transactionsupport
> XATransaction MessageQueueXAConnectionFactoryPool
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-connector-resource
> --poolname MessageQueueXAConnectionFactoryPool
> jms/MessageQueueXAConnectionFactory
> - MDB's are annotated like this:
> @MessageDriven(name = "MyMDB")
> @TransactionManagement(TransactionManagementType.CONTAINER)
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> - sun-ejb-jar.xml has the following configuration-fragments for each MDB:
>
> MyMDB
>
> 16
> 2
> 32
>
>
> activemqra
>
>
>
> destinationType
>
> javax.jms.Queue
>
>
>
> destination
>
> MyWPQ
>
>
>
> maximumRedeliveries
>
> 0
>
>
>
> maxMessagesPerSessions
>
> 100
>
>
>
> maxSessions
>
> 10
>
>
>
>
> - Let me know if you need more info about our setup
>
> Regards, Per Steffensen

Cheng Fang Guest
Offline
Joined: 2011-04-15
Points: 0

Do you experience the same with GlassFish MQ?

Your custom threadpool (mdb-threadpool) is only applied to resource
adapter. MDB has its own thread pool allocation. I believe currently
it only uses the default thread pool. Its pool size is configured with
sun-ejb-jar.xml elements.

-cheng

On 6/15/11 8:32 AM, Per Steffensen wrote:
> Hi
>
> We have a system where MDBs in a JEE application deployed in Glassfish
> v2.1.1 process messages on ActiveMQ v5.4.2-fuse-02-00 queues. In an
> test-setup a test-driver generates a lot of messages on the queues in
> ActiveMQ, so there is always "enough" messages to work with for the
> MDB's. Despite that it does not seem that all MDB-instances as working
> all the time. A lot of other stuff is going on on the system at the
> same time so the system is under a certain amount of load, and that
> might be a parameter in the "algoritm" deciding how many messages
> should be processed concurrently by MDB's?
> But basically I would like to know details about the "alogritm" that
> decides when and how many messages are processed by MDB's concurrently.
> A concrete question is why I experience, when you keep in mind that
> there are plenty of messages to work with, that most of the time not
> even 16 (stady-pool-size) msgs are processed at the same time? I
> believe that there are always "enough" threads in the MDB-driving
> thread-pool (mdb-threadpool - see below).
>
> A little more details about our setup:
> - We have set up a threadpool for MDB processing:
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-threadpool
> --minthreadpoolsize 0 --maxthreadpoolsize 100 --idletimeout 120
> --workqueues 1 mdb-threadpool
> - We are using the resource-adapter that comes with ActiveMQ:
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME deploy --name activemqra
> ./fixed-config/glassfish/activemq-rar-5.4.2-fuse-02-00.rar
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
> create-resource-adapter-config --threadpools mdb-threadpool --property
> ServerUrl=tcp\\://$ACTIVEMQ_HOST\\:$ACTIVEMQ_PORT activemqra
> - We also use the resource-adapter to create a pool of connection to
> ActiveMQ (a.o. used by other processen in the Glassfish application to
> put new messages on ActiveMQ queues)
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME
> create-connector-connection-pool --raname activemqra
> --connectiondefinition javax.jms.ConnectionFactory
> --transactionsupport XATransaction MessageQueueXAConnectionFactoryPool
> $GLASSFISH_INSTALL/bin/$ASADMIN_SCRIPT_NAME create-connector-resource
> --poolname MessageQueueXAConnectionFactoryPool
> jms/MessageQueueXAConnectionFactory
> - MDB's are annotated like this:
> @MessageDriven(name = "MyMDB")
> @TransactionManagement(TransactionManagementType.CONTAINER)
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> - sun-ejb-jar.xml has the following configuration-fragments for each MDB:
>
> MyMDB
>
> 16
> 2
> 32
>
>
> activemqra
>
>
> destinationType
> javax.jms.Queue
>
>
> destination
> MyWPQ
>
>
> maximumRedeliveries
> 0
>
>
> maxMessagesPerSessions
> 100
>
>
> maxSessions
> 10
>
>
>
>
> - Let me know if you need more info about our setup
>
> Regards, Per Steffensen

steff1193
Offline
Joined: 2009-03-24
Points: 0

We are not using Glassfish MQ, so I dont know if we will experience the
same with that. Are you thinking about OpenMQ when you talk about
Glassfish MQ?

What does the resource adaptor need threads (and therefore a thread
pool) for, if it is not for running the handling of messages in MDB's.

I believe there are a difference between bean-pools and thread-pools.
Basically you need to get a thread (from the thread pool) and a
bean-instance (from the bean-pool) to be able to process a message. I
believe they are kind of two separate ways of controlling how much can
run in parallel. Imagine that you have a bean-pool of size 10 for MDB A
and a bean-pool of size 10 for MDB B, and that they are sharing a
thread-pool of size 10. You will have achieved that you can never
handle more than 10 A-messages concurrently, that you can never handle
more than 10 B-messages concurrently, AND that you can never handle
more than 10 A-and/or-B messages concurrently. E.g. if there are 10
A-messages ready to be handled and 10 B-messages ready to be handled,
you will not get them all handled concurrently (due to the thread-pool
size), you might get 5 of each handled concurrently or maybe 8
A-messages and 2 B-messages.

This is just the way I imagine that it works, and the way I know it
works in other JEE app servers (at least in one other JEE app server I
know very well :-) ), but please tell me different if you know that I
am not correct.

So I dont believe you control thread-pool size by settings
in sun-ejb-jar.xml. MDB messages handling might use the default
thread-pool, but then I cannot se why you are assigning a thread-pool
to the resource adapter - the resource adapter that you in
sun-ejb-jar.xml assign to the MDBs. But again please enlighten me you
you KNOW that I am wrong.

Regards, Per Steffensen