Description
Hey guys so the requirement that I have right now is to setup a Queue Listener Spring Boot Application and I am using
spring-cloud-azure-starter-servicebus-jms
for that, but the problem is the default setup mentioned here deletes the message from the queue once I receive it i.e its a destructive read.
My code right now is really simple:
Application name is QueuelistenerApplication
It only contains one file right now i.e QueuelistenerApplication.java with the following code:
package com.queue.listener.queuelistener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
import jakarta.jms.ConnectionFactory;
@SpringBootApplication
@EnableJms
public class QueuelistenerApplication {
private static final String QUEUE_NAME = "test";
public static void main(String[] args) {
SpringApplication.run(QueuelistenerApplication.class, args);
}
@JmsListener(destination = QUEUE_NAME, containerFactory = "jmsListenerContainerFactory")
public void receiveMessage(String message) {
System.out.println("Message received: {}" + message);
}
}
Now I don't want the message to be deleted from the Queue once I've consumed it, Instead what I want is to Peek the Message and Lock it, then do my operations and IF the operations are successful then I can manually acknowledge the message, but IF the operations fails then I want the message to be returned to the Queue. How can I achieve that?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status