-
Notifications
You must be signed in to change notification settings - Fork 605
Implement full async channel #982
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Closed
Closed
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions
19
projects/RabbitMQ.Client/client/FrameworkExtension/Interlocked.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,19 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace RabbitMQ.Client | ||
{ | ||
#if NETCOREAPP3_1 || NETSTANDARD | ||
internal static class Interlocked | ||
{ | ||
public static ulong CompareExchange(ref ulong location1, ulong value, ulong comparand) | ||
{ | ||
return (ulong)System.Threading.Interlocked.CompareExchange(ref Unsafe.As<ulong, long>(ref location1), (long)value, (long)comparand); | ||
} | ||
|
||
public static ulong Increment(ref ulong location1) | ||
{ | ||
return (ulong)System.Threading.Interlocked.Add(ref Unsafe.As<ulong, long>(ref location1), 1L); | ||
} | ||
} | ||
#endif | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
using RabbitMQ.Client.client.impl.Channel; | ||
using RabbitMQ.Client.Events; | ||
|
||
namespace RabbitMQ.Client | ||
|
@@ -12,29 +12,29 @@ public class AsyncDefaultBasicConsumer : IBasicConsumer, IAsyncBasicConsumer | |
private readonly HashSet<string> _consumerTags = new HashSet<string>(); | ||
|
||
/// <summary> | ||
/// Creates a new instance of an <see cref="DefaultBasicConsumer"/>. | ||
/// Creates a new instance of an <see cref="AsyncDefaultBasicConsumer"/>. | ||
/// </summary> | ||
public AsyncDefaultBasicConsumer() | ||
{ | ||
ShutdownReason = null; | ||
Model = null; | ||
Channel = null; | ||
IsRunning = false; | ||
} | ||
|
||
/// <summary> | ||
/// Constructor which sets the Model property to the given value. | ||
/// Constructor which sets the <see cref="Channel"/> property to the given value. | ||
/// </summary> | ||
/// <param name="model">Common AMQP model.</param> | ||
public AsyncDefaultBasicConsumer(IModel model) | ||
/// <param name="channel">The channel.</param> | ||
public AsyncDefaultBasicConsumer(IChannel channel) | ||
{ | ||
ShutdownReason = null; | ||
IsRunning = false; | ||
Model = model; | ||
Channel = channel; | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve the consumer tags this consumer is registered as; to be used when discussing this consumer | ||
/// with the server, for instance with <see cref="IModel.BasicCancel"/>. | ||
/// with the server, for instance with <see cref="IChannel.CancelConsumerAsync"/>. | ||
/// </summary> | ||
public string[] ConsumerTags | ||
{ | ||
|
@@ -50,7 +50,7 @@ public string[] ConsumerTags | |
public bool IsRunning { get; protected set; } | ||
|
||
/// <summary> | ||
/// If our <see cref="IModel"/> shuts down, this property will contain a description of the reason for the | ||
/// If our <see cref="IChannel"/> shuts down, this property will contain a description of the reason for the | ||
/// shutdown. Otherwise it will contain null. See <see cref="ShutdownEventArgs"/>. | ||
/// </summary> | ||
public ShutdownEventArgs ShutdownReason { get; protected set; } | ||
|
@@ -61,10 +61,10 @@ public string[] ConsumerTags | |
public event AsyncEventHandler<ConsumerEventArgs> ConsumerCancelled; | ||
|
||
/// <summary> | ||
/// Retrieve the <see cref="IModel"/> this consumer is associated with, | ||
/// Retrieve the <see cref="IChannel"/> this consumer is associated with, | ||
/// for use in acknowledging received messages, for instance. | ||
/// </summary> | ||
public IModel Model { get; set; } | ||
public IChannel Channel { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love how channel is better aligned with the purpose |
||
|
||
/// <summary> | ||
/// Called when the consumer is cancelled for reasons other than by a basicCancel: | ||
|
@@ -101,7 +101,7 @@ public virtual Task HandleBasicConsumeOk(string consumerTag) | |
/// Called each time a message is delivered for this consumer. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IModel.BasicAck"/> | ||
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IChannel.AckMessageAsync"/> | ||
/// if consuming in automatic acknowledgement mode. | ||
/// Subclasses must copy or fully use delivery body before returning. | ||
/// Accessing the body at a later point is unsafe as its memory can | ||
|
@@ -120,7 +120,7 @@ public virtual Task HandleBasicDeliver(string consumerTag, | |
} | ||
|
||
/// <summary> | ||
/// Called when the model (channel) this consumer was registered on terminates. | ||
/// Called when the channel this consumer was registered on terminates. | ||
/// </summary> | ||
/// <param name="model">A channel this consumer was registered on.</param> | ||
/// <param name="reason">Shutdown context.</param> | ||
|
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
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
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.