On 19 September 2017 at 14:10, Clemens Vasters < [email protected]> wrote:
> 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? > > To be clear this is not *JMS* defined semantics, but an implementation choice in the Qpid JMS client. I'll let Tim / Robbie speak to why that choice was made (if it is intentional). I note there is already a JIRA questioning the pre-fetch behaviour of consumers on stopped connections: https://issues.apache.org/jira/browse/QPIDJMS-297 (albeit this is relating to consumers on connections that were started and then subsequently stopped). -- Rob 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. >
