Skip to content

Commit 6736eda

Browse files
authored
Remove invalid validation (#3)
1 parent 34b0ddb commit 6736eda

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ public type StoreListenerConfiguration record {|
7676
# The interval in seconds between retries for processing a message
7777
decimal retryInterval = 1;
7878
# If true, the message will be acknowledged with a failure after the maximum number of retries.
79-
boolean ackWithFailureAfterMaxRetries = false;
79+
# Else the message will be acknowledged with success
80+
boolean ackWithFailureAfterMaxRetries = true;
8081
# An optional message store to store messages that could not be processed after the maximum
81-
# number of retries. When set, `ackWithFailureAfterMaxRetries` will be ignored
82+
# number of retries. On successful storage, the message will be acknowledged with success
8283
Store deadLetterStore?;
8384
|};
8485
```

ballerina/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ public type StoreListenerConfiguration record {|
7474
# The interval in seconds between retries for processing a message
7575
decimal retryInterval = 1;
7676
# If true, the message will be acknowledged as failed after the maximum number of retries.
77-
boolean ackWithFailureAfterMaxRetries = false;
77+
# Else the message will be acknowledged with success
78+
boolean ackWithFailureAfterMaxRetries = true;
7879
# An optional message store to store messages that could not be processed after the maximum
79-
# number of retries. When set, `ackWithFailureAfterMaxRetries` will be ignored
80+
# number of retries. On successful storage, the message will be acknowledged with success
8081
Store deadLetterStore?;
8182
|};
8283
```

ballerina/msg_listener.bal

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ public type StoreListenerConfiguration record {|
3030
int maxRetries = 3;
3131
# The interval in seconds between retries for processing a message
3232
decimal retryInterval = 1;
33-
# If true, the message will be acknowledged with failure after the maximum number of retries is reached
34-
boolean ackWithFailureAfterMaxRetries = false;
33+
# If true, the message will be acknowledged with failure after the maximum number of retries is reached.
34+
# Else the message will be acknowledged with success.
35+
boolean ackWithFailureAfterMaxRetries = true;
3536
# An optional message store to store messages that could not be processed after the maximum
36-
# number of retries. When set, `ackWithFailureAfterMaxRetries` will be ignored
37+
# number of retries. On successful storage, the message will be acknowledged with success
3738
Store deadLetterStore?;
3839
|};
3940

@@ -61,9 +62,6 @@ public isolated class StoreListener {
6162
if config.retryInterval <= 0d {
6263
return error Error("retryInterval must be greater than zero");
6364
}
64-
if config.deadLetterStore !is () && config.ackWithFailureAfterMaxRetries {
65-
return error Error("ackWithFailureAfterMaxRetries cannot be true when deadLetterStore is set");
66-
}
6765
StoreListenerConfiguration {deadLetterStore, ...otherConfig} = config;
6866
self.config = {
6967
...otherConfig.clone(),
@@ -237,10 +235,9 @@ isolated class PollAndProcessMessages {
237235

238236
if self.config.ackWithFailureAfterMaxRetries {
239237
log:printDebug("max retries reached, acknowledging message with failure", msgId = id);
238+
} else {
239+
log:printDebug("max retries reached, acknowledging message with success", msgId = id);
240240
}
241-
else {
242-
log:printDebug("max retries reached, message is kept in the store", msgId = id);
243-
}
244-
self.ackMessage(id, self.config.ackWithFailureAfterMaxRetries);
241+
self.ackMessage(id, !self.config.ackWithFailureAfterMaxRetries);
245242
}
246243
}

ballerina/tests/msg_store_listener_tests.bal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ listener StoreListener customDeadLetterStoreListenerWithDrop = new (
307307
maxRetries = 1,
308308
retryInterval = 2,
309309
deadLetterStore = customDeadLetterStore,
310-
ackWithFailureAfterMaxRetries = true
310+
ackWithFailureAfterMaxRetries = false
311311
);
312312

313313
listener StoreListener customDeadLetterStoreListenerWithoutDrop = new (
@@ -316,7 +316,7 @@ listener StoreListener customDeadLetterStoreListenerWithoutDrop = new (
316316
maxRetries = 1,
317317
retryInterval = 2,
318318
deadLetterStore = customDeadLetterStore,
319-
ackWithFailureAfterMaxRetries = false
319+
ackWithFailureAfterMaxRetries = true
320320
);
321321

322322
service on customDeadLetterStoreListenerWithDrop, customDeadLetterStoreListenerWithoutDrop {

docs/spec/spec.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ type StoreListenerConfiguration record {|
8686
decimal pollingInterval = 1;
8787
int maxRetries = 3;
8888
decimal retryInterval = 1;
89-
boolean ackWithFailureAfterMaxRetries = false;
89+
boolean ackWithFailureAfterMaxRetries = true;
9090
Store deadLetterStore?;
9191
|};
9292
```
9393

9494
**Key Features:**
95+
9596
- Configurable polling, retry, and DLQ behavior
9697
- Attachable service for message processing
9798
- Graceful and immediate stop operations

0 commit comments

Comments
 (0)