How can I implement the Peek and Lock pattern within the ServiceBusTopicTrigger in Azure Functions without creating a new receiver for receiving messages? I have an Azure Function that successfully receives messages from the Service Bus Topic, but the problem is that the service automatically deletes the messages. I need to process the messages based on the quantity and either complete or abandon them. How can I achieve this using the Peek and Lock pattern without creating a new receiver within the function?
// This is my azure function
public class ServiceBusTopicTriggerJava {
/**
* This function will be invoked when a new message is received at the Service Bus Topic.
*/
@FunctionName("ServiceBusTopicTriggerJava")
public void run(
@ServiceBusTopicTrigger(
name = "message",
topicName = "aftopic",
subscriptionName = "afSubscription",
connection = "ServiceBusConnectionString"
) final List<Sales> message,
final ExecutionContext context
) {
//log go here
}
This is my pojo data
@Data
@Builder
public class Sales {
private String id;
private String itemId;
private String itemName;
private double quantity;
private double price;
}
// this is my message from service bus
[{"id":"6a2a7d07-1b0c-48db-9753-3f32d619ebd5","itemId":"123","itemName":"Item 123","quantity":35.0,"price":10.0}]