|
29 | 29 | // Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
|
30 | 30 | //---------------------------------------------------------------------------
|
31 | 31 |
|
| 32 | +using System; |
32 | 33 | using NUnit.Framework;
|
33 | 34 |
|
34 | 35 | namespace RabbitMQ.Client.Unit
|
@@ -63,5 +64,61 @@ protected void Publish()
|
63 | 64 | {
|
64 | 65 | Model.BasicPublish("", "amq.fanout", null, encoding.GetBytes("message"));
|
65 | 66 | }
|
| 67 | + |
| 68 | + [Test] |
| 69 | + [TestCase(255)] |
| 70 | + [TestCase(256)] |
| 71 | + public void TestDeliveryTagDiverged_GH1043(int correlationIdLength) |
| 72 | + { |
| 73 | + bool.TryParse(Environment.GetEnvironmentVariable("RABBITMQ_VERBOSE"), out bool verbose); |
| 74 | + |
| 75 | + byte[] body = RandomMessageBody(); |
| 76 | + |
| 77 | + Model.ExchangeDeclare("sample", "fanout", autoDelete: true); |
| 78 | + if (verbose) |
| 79 | + { |
| 80 | + Model.BasicAcks += (s, e) => Console.WriteLine("Acked {0}", e.DeliveryTag); |
| 81 | + } |
| 82 | + Model.ConfirmSelect(); |
| 83 | + |
| 84 | + IBasicProperties properties = Model.CreateBasicProperties(); |
| 85 | + if (verbose) |
| 86 | + { |
| 87 | + Console.WriteLine("Client delivery tag {0}", Model.NextPublishSeqNo); |
| 88 | + } |
| 89 | + Model.BasicPublish(exchange: "sample", routingKey: string.Empty, properties, body); |
| 90 | + Model.WaitForConfirmsOrDie(); |
| 91 | + |
| 92 | + try |
| 93 | + { |
| 94 | + properties = Model.CreateBasicProperties(); |
| 95 | + properties.CorrelationId = new string('o', correlationIdLength); |
| 96 | + if (verbose) |
| 97 | + { |
| 98 | + Console.WriteLine("Client delivery tag {0}", Model.NextPublishSeqNo); |
| 99 | + } |
| 100 | + Model.BasicPublish("sample", string.Empty, properties, body); |
| 101 | + Model.WaitForConfirmsOrDie(); |
| 102 | + } |
| 103 | + catch (Exception e) |
| 104 | + { |
| 105 | + if (verbose) |
| 106 | + { |
| 107 | + Console.WriteLine("Error when trying to publish with long string: {0}", e.Message); |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + properties = Model.CreateBasicProperties(); |
| 112 | + if (verbose) |
| 113 | + { |
| 114 | + Console.WriteLine("Client delivery tag {0}", Model.NextPublishSeqNo); |
| 115 | + } |
| 116 | + Model.BasicPublish("sample", string.Empty, properties, body); |
| 117 | + Model.WaitForConfirmsOrDie(); |
| 118 | + if (verbose) |
| 119 | + { |
| 120 | + Console.WriteLine("I'm done..."); |
| 121 | + } |
| 122 | + } |
66 | 123 | }
|
67 | 124 | }
|
0 commit comments