I am testing the AMQP 1.0 with Azure service Bus queue.
When I call message.acknowledge() and I restart the java listener, then I receive again the message from the queue.
This is my code:
sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); sender = sendSession.createProducer(queue); if (runReceiver) { // Create receiver-side Session, MessageConsumer,and MessageListener receiveSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); receiver = receiveSession.createConsumer(queue); receiver.setMessageListener(this); connection.start(); public void onMessage(Message message) { try { //System.out.println("Received message with JMSMessageID = " + message.getJMSMessageID()); String txt = message.getStringProperty("data"); Gson gson = new Gson(); Email email = gson.fromJson(txt, Email.class); System.out.println("Messaggio ricevuto: " + email.From); System.out.println("Messaggio ricevuto: " + email.Body); message.acknowledge(); } catch (Exception e) { e.printStackTrace(); } }
Any suggestion?
Giuseppe