-
Notifications
You must be signed in to change notification settings - Fork 80
Support for (optional) ack timeout and nack delay for consumers #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4eb2b06
Added missing reference to Microsoft.Bcl.AsyncInterfaces in samples a…
dionjansen dfb864a
nack delay option
dionjansen 370e1c8
ack timeout config option
dionjansen 278005f
naive implementation tracker and message queue
dionjansen 79bc906
use message package for queue
dionjansen 546d9e9
use int for ms values
dionjansen 5e3cea6
Non generic interface
dionjansen 19931bc
Added basic implementation for tracker, integrated messagequeue in co…
dionjansen 295eab8
Create conditional tracker in client
dionjansen 2be5114
Inform queue when acking
dionjansen 163ea45
Cleanup references for VSCode
dionjansen 6fc4550
Merge branch 'master' into nack
dionjansen 7da197e
Unacked tracker only
dionjansen d759c06
Cleanup
dionjansen 26cd957
Added test suite for unacked message tracker
dionjansen f4725f5
Refactored elapsed calc
dionjansen 51f4a98
cleanup
dionjansen 0119ca9
Cleanup old tracker
dionjansen 7ad89a2
Apache header for new files
dionjansen a7d5f02
Cleanup inactive message tracker
dionjansen 98850bb
Cleanup stress tests deps
dionjansen 2edfa35
Cleanup message queue and interface
dionjansen b78ac54
Formatting tracker
dionjansen b57668b
Fixed tests naming, separated tests for struct
dionjansen 871dce6
Renamed options, use timespans instad of micros
dionjansen 8841930
Moved IEquatable and IComparable into MessageIdData partial class
dionjansen ddfd374
Renamed ack to full acknowledge, cleaned up tests
dionjansen ad58271
Refactor use for MessageId to MessageIdData, added RedeliverUnacknowl…
dionjansen f02166b
Refactored Start method to not use unnecessary Task.run
dionjansen 5771533
Merge branch 'master' into nack
dionjansen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace DotPulsar.Internal.Abstractions | ||
| { | ||
| using DotPulsar.Internal.PulsarApi; | ||
| using System; | ||
|
|
||
| public interface IMessageQueue : IDequeue<MessagePackage>, IDisposable | ||
| { | ||
| void Acknowledge(MessageIdData messageId); | ||
|
|
||
| void NegativeAcknowledge(MessageIdData messageId); | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/DotPulsar/Internal/Abstractions/IUnacknowledgedMessageTracker.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace DotPulsar.Internal.Abstractions | ||
| { | ||
| using DotPulsar.Abstractions; | ||
| using DotPulsar.Internal.PulsarApi; | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| public interface IUnacknowledgedMessageTracker : IDisposable | ||
| { | ||
| void Add(MessageIdData messageId); | ||
|
|
||
| void Acknowledge(MessageIdData messageId); | ||
|
|
||
| Task Start(IConsumer consumer, CancellationToken cancellationToken = default); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace DotPulsar.Internal | ||
| { | ||
| using Abstractions; | ||
| using PulsarApi; | ||
| using DotPulsar.Abstractions; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| public sealed class InactiveUnackedMessageTracker : IUnacknowledgedMessageTracker | ||
| { | ||
|
|
||
| public void Acknowledge(MessageIdData messageId) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| public void Add(MessageIdData messageId) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| public Task Start(IConsumer consumer, CancellationToken cancellationToken = default) => Task.CompletedTask; | ||
|
|
||
| public void Dispose() | ||
| { | ||
| return; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace DotPulsar.Internal | ||
dionjansen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| using Abstractions; | ||
| using PulsarApi; | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| public sealed class MessageQueue : IMessageQueue | ||
| { | ||
| private readonly AsyncQueue<MessagePackage> _queue; | ||
| private readonly IUnacknowledgedMessageTracker _tracker; | ||
|
|
||
| public MessageQueue(AsyncQueue<MessagePackage> queue, IUnacknowledgedMessageTracker tracker) | ||
| { | ||
| _queue = queue; | ||
| _tracker = tracker; | ||
| } | ||
|
|
||
| public async ValueTask<MessagePackage> Dequeue(CancellationToken cancellationToken = default) | ||
| { | ||
| var message = await _queue.Dequeue(cancellationToken).ConfigureAwait(false); | ||
| _tracker.Add(message.MessageId); | ||
| return message; | ||
| } | ||
|
|
||
| public void Acknowledge(MessageIdData obj) => _tracker.Acknowledge(obj); | ||
|
|
||
| public void NegativeAcknowledge(MessageIdData obj) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| _queue.Dispose(); | ||
| _tracker.Dispose(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace DotPulsar.Internal.PulsarApi | ||
| { | ||
| using System; | ||
|
|
||
| public partial class MessageIdData : IEquatable<MessageIdData>, IComparable<MessageIdData> | ||
| { | ||
| public int CompareTo(MessageIdData? other) | ||
| { | ||
| if (other is null) | ||
| return 1; | ||
|
|
||
| var result = LedgerId.CompareTo(other.LedgerId); | ||
| if (result != 0) | ||
| return result; | ||
|
|
||
| result = EntryId.CompareTo(other.EntryId); | ||
| if (result != 0) | ||
| return result; | ||
|
|
||
| result = Partition.CompareTo(other.Partition); | ||
| if (result != 0) | ||
| return result; | ||
|
|
||
| return BatchIndex.CompareTo(other.BatchIndex); | ||
| } | ||
|
|
||
| public bool Equals(MessageIdData? other) | ||
| => other is not null && LedgerId == other.LedgerId && EntryId == other.EntryId && Partition == other.Partition && BatchIndex == other.BatchIndex; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.