Skip to content

Commit 10246a5

Browse files
committed
Update RabbitMQ version
from our dockerhub repo to the official repo Signed-off-by: Gabriele Santomaggio <[email protected]>
1 parent 06262ea commit 10246a5

File tree

9 files changed

+121
-95
lines changed

9 files changed

+121
-95
lines changed

.ci/publish-documentation-to-github-pages.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

.ci/ubuntu/cluster/gha-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function run_docker_compose
2121

2222
if [[ $2 == 'arm' ]]
2323
then
24-
readonly rabbitmq_image="${RABBITMQ_IMAGE:-pivotalrabbitmq/rabbitmq-arm64:main}"
24+
readonly rabbitmq_image="${RABBITMQ_IMAGE:-rabbitmq1:4-management}"
2525
else
26-
readonly rabbitmq_image="${RABBITMQ_IMAGE:-pivotalrabbitmq/rabbitmq:main}"
26+
readonly rabbitmq_image="${RABBITMQ_IMAGE:-rabbitmq1:4-management}"
2727
fi
2828

2929
if [[ ! -v GITHUB_ACTIONS ]]

.ci/ubuntu/one-node/gha-setup.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
readonly script_dir
99
echo "[INFO] script_dir: '$script_dir'"
1010

11-
if [[ $3 == 'arm' ]]
12-
then
13-
readonly rabbitmq_image="${RABBITMQ_IMAGE:-pivotalrabbitmq/rabbitmq-arm64:main}"
14-
else
15-
readonly rabbitmq_image="${RABBITMQ_IMAGE:-pivotalrabbitmq/rabbitmq:main}"
16-
fi
11+
readonly rabbitmq_image="${RABBITMQ_IMAGE:-rabbitmq:4-management}"
1712

1813

1914
readonly docker_name_prefix='rabbitmq-amqp-dotnet-client'

.ci/windows/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"erlang": "27.0.1",
3-
"rabbitmq": "4.0.0-beta.6"
3+
"rabbitmq": "4.0.2"
44
}

.github/workflows/wf_build-and-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
id: install-start-rabbitmq
3535
run: ${{ github.workspace }}\.ci\windows\gha-setup.ps1
3636
- name: Test
37-
timeout-minutes: 20
37+
timeout-minutes: 25
3838
run: dotnet test ${{ github.workspace }}\Build.csproj --no-restore --no-build --logger 'console;verbosity=detailed'
3939
- name: Check for errors in RabbitMQ logs
4040
run: ${{ github.workspace }}\.ci\windows\gha-log-check.ps1
@@ -64,7 +64,7 @@ jobs:
6464
id: start-rabbitmq
6565
run: ${{ github.workspace }}/.ci/ubuntu/cluster/gha-setup.sh
6666
- name: Test
67-
timeout-minutes: 20
67+
timeout-minutes: 25
6868
run: dotnet test ${{ github.workspace }}/Build.csproj --no-restore --no-build --logger "console;verbosity=detailed"
6969
- name: Check for errors in RabbitMQ logs
7070
run: ${{ github.workspace}}/.ci/ubuntu/cluster/gha-logs.sh check

Makefile

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,8 @@ build:
99
test: build
1010
dotnet test -c Debug $(CURDIR)/Tests/Tests.csproj --no-build --logger:"console;verbosity=detailed"
1111

12-
rabbitmq-server-start-arm:
13-
./.ci/ubuntu/one-node/gha-setup.sh start pull arm
12+
rabbitmq-server-start:
13+
./.ci/ubuntu/one-node/gha-setup.sh start pull
1414

1515
rabbitmq-server-stop:
1616
./.ci/ubuntu/one-node/gha-setup.sh stop
17-
18-
19-
# TODO:
20-
## publish the documentation on github pages
21-
## you should execute this command only on the `main` branch
22-
# publish-github-pages:
23-
# ## Create the PDF
24-
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor-pdf index.adoc"
25-
# ## Create the HTML
26-
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor index.adoc"
27-
# ## copy the PDF and HTML to temp folder
28-
# rm -rf docs/temp
29-
# mkdir -p docs/temp
30-
# cp docs/asciidoc/index.pdf docs/temp/dotnet-stream-client.pdf
31-
# cp docs/asciidoc/index.html docs/temp/index.html
32-
# ## check out the gh-pages branch
33-
# git checkout gh-pages
34-
# ## copy the PDF and HTML to the root folder
35-
# mv docs/temp/dotnet-stream-client.pdf stable/dotnet-stream-client.pdf
36-
# mv docs/temp/index.html stable/htmlsingle/index.html
37-
# ## commit and push
38-
# git add stable/dotnet-stream-client.pdf
39-
# git add stable/htmlsingle/index.html
40-
# git commit -m "Update the documentation"
41-
# git push origin gh-pages
42-
# ## go back to the main branch
43-
# git checkout main

RabbitMQ.AMQP.Client/IConsumer.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,63 @@ public interface IConsumer : ILifeCycle
2626

2727
public interface IContext
2828
{
29+
///<summary>
30+
/// Accept the message (AMQP 1.0 <code>accepted</code> outcome).
31+
///
32+
///This means the message has been processed and the broker can delete it.
33+
///
34+
/// </summary>
2935
Task AcceptAsync();
36+
37+
///<summary>
38+
/// Discard the message (AMQP 1.0 <code>rejected</code> outcome).
39+
///This means the message cannot be processed because it is invalid, the broker can drop it
40+
/// or dead-letter it if it is configured.
41+
///</summary>
3042
Task DiscardAsync();
43+
44+
///<summary>
45+
///Discard the message with annotations to combine with the existing message annotations.
46+
///This means the message cannot be processed because it is invalid, the broker can drop it
47+
///or dead-letter it if it is configured.
48+
///Application-specific annotation keys must start with the <code>x-opt-</code> prefix.
49+
///Annotation keys the broker understands starts with <code>x-</code>, but not with <code>x-opt-
50+
///</code>.
51+
///This maps to the AMQP 1.0 <code>
52+
///modified{delivery-failed = true, undeliverable-here = true}</code> outcome.
53+
///@param annotations message annotations to combine with existing ones
54+
///@see <a
55+
/// href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">AMQP
56+
/// 1.0 <code>modified</code> outcome</a>
57+
///</summary>
3158
Task DiscardAsync(Dictionary<string, object> annotations);
3259

60+
///<summary>
61+
///Requeue the message (AMQP 1.0 <code>released</code> outcome).
62+
///
63+
///This means the message has not been processed and the broker can requeue it and deliver it
64+
/// to the same or a different consumer.
65+
///
66+
/// </summary>
3367
Task RequeueAsync();
68+
69+
///<summary>
70+
///Requeue the message with annotations to combine with the existing message annotations.
71+
///
72+
///This means the message has not been processed and the broker can requeue it and deliver it
73+
/// to the same or a different consumer.
74+
/// Application-specific annotation keys must start with the <code>x-opt-</code> prefix.
75+
/// Annotation keys the broker understands starts with <code>x-</code>, but not with <code>x-opt-
76+
/// </code>.
77+
///
78+
/// This maps to the AMQP 1.0 <code>
79+
/// modified{delivery-failed = false, undeliverable-here = false}</code> outcome.
80+
///
81+
/// @param annotations message annotations to combine with existing ones
82+
///@see <a
83+
/// href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">AMQP
84+
/// 1.0 <code>modified</code> outcome</a>
85+
///</summary>
3486
Task RequeueAsync(Dictionary<string, object> annotations);
3587
}
3688
}

RabbitMQ.AMQP.Client/Impl/DeliveryContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public Task DiscardAsync(Dictionary<string, object> annotations)
6262
{
6363
throw new ConsumerException("Link is closed");
6464
}
65-
6665
Utils.ValidateMessageAnnotations(annotations);
6766

6867
Task rejectTask = Task.Run(() =>

Tests/Consumer/ConsumerOutcomeTests.cs

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,67 @@ public void ValidateAnnotations()
2424

2525
const string correctAnnotationKey = "x-otp-annotation-key";
2626
// This should not throw an exception because the annotation key starts with "x-"
27-
Utils.ValidateMessageAnnotations(new Dictionary<string, object>
28-
{
29-
{ correctAnnotationKey, annotationValue }
30-
});
27+
Utils.ValidateMessageAnnotations(new Dictionary<string, object> { { correctAnnotationKey, annotationValue } });
28+
}
29+
30+
31+
[Fact]
32+
public async Task RequeuedMessageWithAnnotationShouldContainAnnotationsOnRedelivery()
33+
{
34+
Assert.NotNull(_connection);
35+
Assert.NotNull(_management);
36+
TaskCompletionSource<bool> tcsRequeue =
37+
new(TaskCreationOptions.RunContinuationsAsynchronously);
38+
39+
const string annotationKey = "x-opt-annotation-key";
40+
const string annotationValue = "annotation-value";
41+
42+
const string annotationKey1 = "x-opt-annotation1-key";
43+
const string annotationValue1 = "annotation1-value";
44+
45+
int requeueCount = 0;
46+
47+
48+
await _management.Queue().Type(QueueType.QUORUM).Name(_queueName).DeclareAsync();
49+
List<IMessage> messages = [];
50+
IPublisher publisher = await _connection.PublisherBuilder().Queue(_queueName).BuildAsync();
51+
IConsumer consumer = await _connection.ConsumerBuilder().MessageHandler(
52+
async (context, message) =>
53+
{
54+
messages.Add(message);
55+
if (requeueCount == 0)
56+
{
57+
requeueCount++;
58+
await context.RequeueAsync(new Dictionary<string, object>
59+
{
60+
{ annotationKey, annotationValue }, { annotationKey1, annotationValue1 }
61+
});
62+
}
63+
else
64+
{
65+
await context.AcceptAsync();
66+
tcsRequeue.SetResult(true);
67+
}
68+
}
69+
).Queue(_queueName).BuildAndStartAsync();
70+
71+
IMessage message = new AmqpMessage($"message");
72+
PublishResult pr = await publisher.PublishAsync(message);
73+
74+
Assert.Equal(OutcomeState.Accepted, pr.Outcome.State);
75+
76+
await tcsRequeue.Task.WaitAsync(TimeSpan.FromSeconds(5));
77+
78+
Assert.Equal(2, messages.Count);
79+
Assert.Null(messages[0].Annotation(annotationKey));
80+
Assert.Null(messages[0].Annotation(annotationKey1));
81+
Assert.Null(messages[0].Annotation("x-delivery-count"));
82+
83+
Assert.Equal(messages[1].Annotation(annotationKey), annotationValue);
84+
Assert.Equal(messages[1].Annotation(annotationKey1), annotationValue1);
85+
Assert.NotNull(messages[1].Annotation("x-delivery-count"));
86+
87+
await consumer.CloseAsync();
3188
}
3289

3390
[Fact]
@@ -67,7 +124,6 @@ public async Task DiscardedMessageWithAnnotationsShouldBeDeadLeadLetteredAndCont
67124
}).Queue(dlqQueueName).BuildAndStartAsync();
68125

69126
IMessage mResult = await tcsDl.Task.WaitAsync(TimeSpan.FromSeconds(5));
70-
71127
Assert.NotNull(mResult);
72128
Assert.Equal(mResult.Annotation(annotationKey), annotationValue);
73129
await dlConsumer.CloseAsync();

0 commit comments

Comments
 (0)