Well I'm not sure about those 5 seconds, I think it makes sense only if
the consumer starts consuming and the connector was not started.
I agree, is perfectly normal to create multiple consumers for the same
connection and then start the connection, but if I consume before the
connection was started, a warning could help to figure out why nothing came.
James Strachan wrote:
This is a pretty standard gotcha in JMS...
http://activemq.org/I+am+not+receiving+any+messages%2C+what+is+wrong
one of the problems is its perfectly legal to create consumers before
the connection is started (its often good practice to create all your
JMS resources first, then start the connection.
I guess it might be nice to create some kind of warning in the log, if
a connection and consumers are created, but the connection is not
started for say 5 seconds, to send a warning to the log that the
connection has not been started yet.
James
On 4/11/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:
Me again, finally after some debug, I notice that the connection was not
started. Anyway, there should a a worning in the log, I think, in case
you try to consume and the connections is not started? Maybe? It seems
that when the connector was not started, some memory queue is queried
for messages.
Adrian Tarau wrote:
I have a problem with ActiveMQ 3.2.2, cannot get it to work properly.
You can see bellow relevant fragments from the code.
Everything happens in one class with ActiveMQ initialized with vm
connector(embedded) and derby as persistence.
I call the consumer section and no messages comes, even if I queried
the derby database and all the messages are there.
I initialized also a queue browser and nothing came. There are no
exceptions. Do I use something in a wrong way? Where can I look for
problems?
Thanks.
I initialize the queue
try {
session = manager.getManagerJMS().createSession();
queue = session.createQueue(getId());
} catch (JMSException e) {
LOG.error("Cannot initialize JMS queue " + getId(), e);
}
I have a producer,
MessageProducer producer = session.createProducer(queue);
try {
ObjectMessage message = session.createObjectMessage(task);
if (task.getMessage() instanceof MessagingMessage) {
MessagingMessage taskMessage = (MessagingMessage)
task.getMessage();
message.setStringProperty("From",
taskMessage.getSender().getValue());
message.setStringProperty("To",
Utilities.getAddressesDisplay(taskMessage.getReceivers()));
}
producer.send(message, DeliveryMode.PERSISTENT,
getJMSPriority(task), timeToLive);
if (maxCount == Integer.MAX_VALUE) {
SamsManager.LOG.info("Reschedule job, " +
count.incrementAndGet() + " jobs in " + getQueueLoggingString(false));
} else {
SamsManager.LOG.info("Schedule job, " +
count.incrementAndGet() + " jobs in " + getQueueLoggingString(false));
}
} finally {
producer.close();
}
and I have the consumer,
MessageConsumer consumer = session.createConsumer(queue);
try {
Message message = consumer.receive(waitAvailable);
if (message == null) return null;
if (message instanceof ObjectMessage) {
task = ((ObjectMessage) message).getObject();
} else {
LOG.error("Message is not an instanceof
ObjectMessage" + message);
}
} finally {
consumer.close();
}
Queue browser :
QueueBrowser browser = session.createBrowser(queue);
Enumeration enumeration = browser.getEnumeration();
while (enumeration.hasMoreElements()) {
Message message = (Message) enumeration.nextElement();
LOG.debug("message : " + message);
}
--
James
-------
http://radio.weblogs.com/0112098/