You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Alice Boxhall <ab...@aconex.com> on 2006/02/07 02:01:10 UTC
Problems with MessageQueue
Hi,
We are running ActiveMQ 3.2.1 with the attached activemq.xml.
Initially everything works fine, then after some time (our very small
sample gives us an average of two days or so) the QueueBrowser won't
pick up new messages. Even though we can see messages persisted in the
database for the queue we want, the QueueBrowser doesn't seem to pick
them up.
ActiveMQ is started with the following block of code:
String brokerURL = appProp.getProperty(BROKER_URL); //
reliable:tcp://index1.mel.prod.aconex.com:62002 ; a machine on the same
network
setBrokerURL(brokerURL);
String username = appProp.getProperty(USERNAME); // blank
setUsername(username);
String password = appProp.getProperty(PASSWORD); // blank
setPassword(password);
if (StringUtils.isBlank(brokerURL) ||
brokerURL.equals(EMPTY_BROKER_URL)) {
LOG.error("ActiveMQ Broker URL is NOT CORRECT! Will
not be able to broadcast stuff via JMS");
throw new IllegalArgumentException(
"ActiveMQ Broker URL is NOT CORRECT! Will
not be able to broadcast stuff via JMS");
} else {
LOG.info("Using broker URL '" + brokerURL + "' to
connect to ActiveMQ");
if (StringUtils.isBlank(username) ||
username.equals(EMPTY_USERNAME)
|| StringUtils.isBlank(password) ||
password.equals(EMPTY_PASSWORD)) {
LOG.info("Not using username or password to
connect to ActiveMQ");
connectionFactory = new
ActiveMQConnectionFactory(brokerURL);
} else {
connectionFactory = new
ActiveMQConnectionFactory(username, password,
brokerURL);
}
LOG.info("ConnectionFactory created successfully.");
}
The place where we are seeing the problems is in a run loop for a thread:
outerwhile: while (true) {
// need to create a browser each time through
QueueBrowser browser = null;
PdfRequest pdfRequest = null;
try {
browser = session.createBrowser(waitQueue);
Enumeration msgs = null;
msgs = browser.getEnumeration();
// snip...
while (msgs.hasMoreElements()) {
if(LOG.isDebugEnabled()) {
LOG.debug("Found some jobs to inspect");
}
Object o = msgs.nextElement();
if(!(o instanceof ObjectMessage)) {
LOG.warn("Non ObjectMessage object found on
waiting requests queue: " + o.getClass());
continue;
}
ObjectMessage message = (ObjectMessage) o;
if(LOG.isDebugEnabled()) {
LOG.debug(message.toString());
}
// snip...
if (pdfRequestStatus != PdfGenerator.REQUEST_PENDING
&& pdfRequestStatus !=
PdfGenerator.UNKNOWN) {
// snip...
if (browser != null) {
if(LOG.isDebugEnabled()) {
LOG.debug("Closing the QueueBrowser
so we can consume the message");
}
try {
browser.close();
} catch (Exception e) {
LOG.error("Failed to close the
QueueBrowser", e);
}
browser = null;
}
consumeRequestFromWaitQueue(pdfRequest);
LOG.info("Exiting inspection loop, will
process others next iteration");
continue outerWhile;
} // end if
} // end inner while
} catch (Throwable e) {
LOG.error("Failure during run loop to inspect the
wait queue", e);
} finally {
if (browser != null) {
try {
browser.close();
} catch (Exception e) {
LOG.error("Failed to close the
QueueBrowser", e);
}
}
}
// snipped sleep for 5000 msec
} // end outerwhile
Where we would expect to see debug messages telling us that there were
waiting messages (which we know are there as we can see them persisted
to the DB) there is nothing, although we are getting debug messages
telling us that the loop is running. I have double-checked that wherever
a QueueBrowser is used it is closed in a finally block as it is in the
sample code above.
Would someone be able to point out if there are any obvious problems in
our set-up, or are there any known issues which would cause this behaviour?