users@glassfish.java.net

Re: What exactly means NumMsgsHeldInTransaction and NumMsgsPendingAcks in JMS Destinations?

From: Gustavo Henrique Orair <gustavo.orair_at_gmail.com>
Date: Wed, 14 Dec 2011 21:01:21 -0200

I am not sure but this problem may be related to JMX technology. So, if it
is the case, I am trying to tell what exactly better my code.

My JMS producers are being invoked by JMX.

In fact, I have an EJB Singleton JMXServiceActivator may be invoked to
perform JMX enabled tasks, such as ExtractLastYearReports,
ExtractLastMonthReports, ExtractLastWeekReports and ExtractLastDayReports.
This JMXServiceActivator do not have any complex logic, it just inject and
invoke a Stateless EJB that I call ExtractorScheduler (their methods may
execute in programmed hours also).

The Stateless EJB will just iterate (30 times for ExtractLastMonthReports,
7 times for ExtractLastWeekReports). For each iteration, a new Extractor
object is created and Extractor execute an extraction. The extraction
method access the filesystem, get a Report Business Object and send this
report to a queue. The JMS connection pool and JMS queue are scoped inside
a dispatch method invoked by the extraction method.

Strangely, the messages are just "unlocked" (not held in transaction) when
all iterations are done. In the case I have too many reports, such as
ExtractLastYearReports, the producers stop working because no more
connection are available in Connection Factory.

Is this a JMX related bug or am I missing something?

BR,
---------------------------------------------------------------------------------------------------------------------
                               Gustavo Henrique Orair
 Mestre em Ciência da Computação - MSc in Computer Science
                                    Universidade Federal de Minas Gerais
               Celular/Cell phone: 55-31-85157887
------------------------------------------------------------------------------------------------------------------


2011/12/14 Gustavo Henrique Orair <gustavo.orair_at_gmail.com>

> Sorry, if it is a very noob question but I have some problems using JMS.
>
> I have some producers that obtain the JMS resources (Connection Factory
> and Queue) using explicitly JNDI.
>
> So I create a session using connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE).
> I assume that as I created the session with first parameter to false, no
> transactions are involved and this is really the behaviour I need.
>
> I have an iteration that basically change the object inside ObjectMessage:
> msg.setObject(objetoCorrente);
> And send the message
> produtorMsg.send(msg);
>
>
> When monitoring using Jconsole I see the NumMsgs equals to zero while
> NumMsgsPendingAcks and NumMsgsHeldInTransaction increases simultaneously.
> For some reason, looks like the transacted==false are not being honored
> and no msgs are being sent before the session is closed.
>
> Could someone explain me better what exactly NumMsgsPendingAcks and
> NumMsgsHeldInTransaction means? And which could be my problem?
>
> Best,
>
> ---------------------------------------------------------------------------------------------------------------------
> Gustavo Henrique Orair
>
> ------------------------------------------------------------------------------------------------------------------
>