Skip to content

Commit

Permalink
alow a list of ids to be acked or rolled back
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuckton committed Jan 7, 2025
1 parent 312c990 commit 5508c05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> 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<Long> messageId) {
SubscribedEventManager subscribedEventManager = subscribedEventManagerMap.get(destination);
if (subscribedEventManager != null) {
subscribedEventManager.rollbackReceived(messageId);
for (long id : messageId) {
subscribedEventManager.rollbackReceived(id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> eventIds;
}

0 comments on commit 5508c05

Please sign in to comment.