This may be my ignorance of JMS details, but why does a Qpid JMS consumer go
off and happily prefetch messages when its associated Session/Connection hasn't
even been start()'ed yet?
I just got misled by the trace output into believing that my app code's
receive/callback usage was wrong.
Here:
Connection connection = cf.createConnection(csb.getSasKeyName(),
csb.getSasKey());
// Create Session, no transaction, client ack
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
// Create consumer
MessageConsumer consumer = session.createConsumer(queue);
consumer.setMessageListener(message -> {
try {
// receives message is passed to callback
logger.info(String.format("Received message %d with sq#: %s",
totalReceived.incrementAndGet(), message.getJMSMessageID()));
message.acknowledge();
} catch (Exception e) {
logger.error(e);
}
});
//connection.start();
If I just let the app spin after this, it'll start logging prefetch events
...
2017-09-19 14:04:42,515 [windows.net:-1]] - TRACE AmqpProvider
- New Proton Event: DELIVERY
2017-09-19 14:04:42,515 [windows.net:-1]] - TRACE AmqpConsumer
- AmqpConsumer { ID:fce87003-90ac-4fb9-8e83-fdb4cd975a6a:2:1:1 } has incoming
Message(s).
2017-09-19 14:04:42,517 [windows.net:-1]] - DEBUG AmqpConsumer
- Dispatching received message: JmsInboundMessageDispatch { sequence = 1,
messageId = ID:21a39efc-8501-45e8-8c67-d3483ca03874:1:1:1-5, consumerId =
ID:fce87003-90ac-4fb9-8e83-fdb4cd975a6a:2:1:1 }
...
But my callback is never invoked.
Once I call start() on the connection (which I now do right after creating the
connection in my code), the callback does get invoked.
That is quite confusing.