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);
}