From 5508c051f58ec18df401b428e44f29892bcb2563 Mon Sep 17 00:00:00 2001 From: Matthew Buckton Date: Tue, 7 Jan 2025 20:56:39 +1100 Subject: [PATCH] alow a list of ids to be acked or rolled back --- .../rest/api/impl/messaging/MessagingApi.java | 4 ++-- .../api/impl/messaging/impl/RestMessageListener.java | 12 ++++++++---- .../rest/responses/TransactionData.java | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/mapsmessaging/rest/api/impl/messaging/MessagingApi.java b/src/main/java/io/mapsmessaging/rest/api/impl/messaging/MessagingApi.java index 82735d740..23c725c8f 100644 --- a/src/main/java/io/mapsmessaging/rest/api/impl/messaging/MessagingApi.java +++ b/src/main/java/io/mapsmessaging/rest/api/impl/messaging/MessagingApi.java @@ -101,7 +101,7 @@ public StatusResponse subscribeToTopic(@Valid SubscriptionRequestDTO subscriptio public StatusResponse commitMessages(@Valid TransactionData transactionData) { hasAccess(RESOURCE); RestMessageListener messageListener = (RestMessageListener) getSession().getAttribute("restListener"); - messageListener.ackReceived(transactionData.getDestinationName(), transactionData.getEventId()); + messageListener.ackReceived(transactionData.getDestinationName(), transactionData.getEventIds()); return new StatusResponse("Successfully committed messages"); } @@ -116,7 +116,7 @@ public StatusResponse commitMessages(@Valid TransactionData transactionData) { public StatusResponse abortMessages(@Valid TransactionData transactionData) { hasAccess(RESOURCE); RestMessageListener messageListener = (RestMessageListener) getSession().getAttribute("restListener"); - messageListener.nakReceived(transactionData.getDestinationName(), transactionData.getEventId()); + messageListener.nakReceived(transactionData.getDestinationName(), transactionData.getEventIds()); return new StatusResponse("Successfully aborted messages"); } diff --git a/src/main/java/io/mapsmessaging/rest/api/impl/messaging/impl/RestMessageListener.java b/src/main/java/io/mapsmessaging/rest/api/impl/messaging/impl/RestMessageListener.java index d0b2f68e0..f1c10d28f 100644 --- a/src/main/java/io/mapsmessaging/rest/api/impl/messaging/impl/RestMessageListener.java +++ b/src/main/java/io/mapsmessaging/rest/api/impl/messaging/impl/RestMessageListener.java @@ -62,17 +62,21 @@ public synchronized void sendMessage(@NotNull @NonNull MessageEvent messageEvent } } - public void ackReceived(String destination, long messageId) { + public void ackReceived(String destination, List messageId) { SubscribedEventManager subscribedEventManager = subscribedEventManagerMap.get(destination); if (subscribedEventManager != null) { - subscribedEventManager.ackReceived(messageId); + for (long id : messageId) { + subscribedEventManager.ackReceived(id); + } } } - public void nakReceived(String destination, long messageId) { + public void nakReceived(String destination, List messageId) { SubscribedEventManager subscribedEventManager = subscribedEventManagerMap.get(destination); if (subscribedEventManager != null) { - subscribedEventManager.rollbackReceived(messageId); + for (long id : messageId) { + subscribedEventManager.rollbackReceived(id); + } } } diff --git a/src/main/java/io/mapsmessaging/rest/responses/TransactionData.java b/src/main/java/io/mapsmessaging/rest/responses/TransactionData.java index 29e68f5a2..d2fcd79e5 100644 --- a/src/main/java/io/mapsmessaging/rest/responses/TransactionData.java +++ b/src/main/java/io/mapsmessaging/rest/responses/TransactionData.java @@ -4,10 +4,12 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @Data @AllArgsConstructor @NoArgsConstructor public class TransactionData { private String destinationName; - private long eventId; + private List eventIds; }