Skip to content

Commit 8f158fd

Browse files
committed
Merge branch 'release/2.6'
2 parents 6a6f6e5 + 5a90c1e commit 8f158fd

34 files changed

+968
-415
lines changed

Examples/03-FlowRequestResponse/SimpleFlowController.cs

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public struct StartData
3131
// Public fields will be stored.
3232
public DateTime RequestStartTime;
3333

34+
35+
// Be sure not to accidentally use any public fields that aren't serializable, for example:
36+
//public TaskCompletionSource<bool> SerializationFail = new TaskCompletionSource<bool>();
37+
//
38+
// In the Newtonsoft.Json version at the time of writing, this will not result in an exception but instead hang the flow!
39+
3440

3541
public SimpleFlowController(IFlowProvider flowProvider, IExampleState exampleState)
3642
{

07-ParallelizationTest/07-ParallelizationTest.csproj Examples/07-ParallelizationTest/07-ParallelizationTest.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="..\Examples\ExampleLib\ExampleLib.csproj" />
15-
<ProjectReference Include="..\Examples\Messaging.TapetiExample\Messaging.TapetiExample.csproj" />
16-
<ProjectReference Include="..\Tapeti.SimpleInjector\Tapeti.SimpleInjector.csproj" />
17-
<ProjectReference Include="..\Tapeti\Tapeti.csproj" />
14+
<ProjectReference Include="..\ExampleLib\ExampleLib.csproj" />
15+
<ProjectReference Include="..\Messaging.TapetiExample\Messaging.TapetiExample.csproj" />
16+
<ProjectReference Include="..\..\Tapeti.SimpleInjector\Tapeti.SimpleInjector.csproj" />
17+
<ProjectReference Include="..\..\Tapeti\Tapeti.csproj" />
1818
</ItemGroup>
1919

2020
</Project>

07-ParallelizationTest/Program.cs Examples/07-ParallelizationTest/Program.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
7272

7373

7474
var publisher = dependencyResolver.Resolve<IPublisher>();
75-
Console.WriteLine($"Publishing {MessageCount * RepeatBatch} messages...");
75+
Console.WriteLine($"Publishing first {MessageCount} of {MessageCount * RepeatBatch} messages...");
7676

77-
await PublishMessages(publisher, MessageCount * RepeatBatch);
77+
await PublishMessages(publisher, MessageCount);
7878

7979

80-
81-
Console.WriteLine("Consuming messages...");
80+
Console.WriteLine("Consuming messages while publishing the rest...");
8281
await subscriber.Resume();
82+
83+
await PublishMessages(publisher, MessageCount * (RepeatBatch - 1));
84+
8385
await waitForDone();
8486
}
8587

Tapeti.Cmd/Commands/ShovelCommand.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ public int Execute(IModel sourceChannel, IModel targetChannel, IRateLimiter rate
2222
// No more messages on the queue
2323
break;
2424

25+
// Since RabbitMQ client 6 we need to copy the body before calling another channel method
26+
// like BasicPublish, or the published body will be corrupted
27+
var bodyCopy = result.Body.ToArray();
28+
2529

2630
rateLimiter.Execute(() =>
2731
{
28-
targetChannel.BasicPublish("", TargetQueueName, result.BasicProperties, result.Body);
32+
targetChannel.BasicPublish("", TargetQueueName, result.BasicProperties, bodyCopy);
2933
messageCount++;
3034

3135
if (RemoveMessages)

Tapeti.Cmd/Mock/MockBasicProperties.cs

+67-70
Original file line numberDiff line numberDiff line change
@@ -79,91 +79,88 @@ public void ClearUserId()
7979
throw new NotImplementedException();
8080
}
8181

82-
public bool IsAppIdPresent()
83-
{
84-
throw new NotImplementedException();
85-
}
82+
public bool IsAppIdPresent() => appIdPresent;
83+
public bool IsClusterIdPresent() => clusterIdPresent;
84+
public bool IsContentEncodingPresent() => contentEncodingPresent;
85+
public bool IsContentTypePresent() => contentTypePresent;
86+
public bool IsCorrelationIdPresent() => correlationIdPresent;
87+
public bool IsDeliveryModePresent() => deliveryModePresent;
88+
public bool IsExpirationPresent() => expirationPresent;
89+
public bool IsHeadersPresent() => headersPresent;
90+
public bool IsMessageIdPresent() => messageIdPresent;
91+
public bool IsPriorityPresent() => priorityPresent;
92+
public bool IsReplyToPresent() => replyToPresent;
93+
public bool IsTimestampPresent() => timestampPresent;
94+
public bool IsTypePresent() => typePresent;
95+
public bool IsUserIdPresent() => userIdPresent;
96+
8697

87-
public bool IsClusterIdPresent()
88-
{
89-
throw new NotImplementedException();
90-
}
98+
private bool appIdPresent;
99+
private string appId;
91100

92-
public bool IsContentEncodingPresent()
93-
{
94-
throw new NotImplementedException();
95-
}
101+
private bool clusterIdPresent;
102+
private string clusterId;
96103

97-
public bool IsContentTypePresent()
98-
{
99-
throw new NotImplementedException();
100-
}
104+
private bool contentEncodingPresent;
105+
private string contentEncoding;
101106

102-
public bool IsCorrelationIdPresent()
103-
{
104-
throw new NotImplementedException();
105-
}
107+
private bool contentTypePresent;
108+
private string contentType;
106109

107-
public bool IsDeliveryModePresent()
108-
{
109-
throw new NotImplementedException();
110-
}
110+
private bool correlationIdPresent;
111+
private string correlationId;
111112

112-
public bool IsExpirationPresent()
113-
{
114-
throw new NotImplementedException();
115-
}
113+
private bool deliveryModePresent;
114+
private byte deliveryMode;
116115

117-
public bool IsHeadersPresent()
118-
{
119-
throw new NotImplementedException();
120-
}
116+
private bool expirationPresent;
117+
private string expiration;
121118

122-
public bool IsMessageIdPresent()
123-
{
124-
throw new NotImplementedException();
125-
}
119+
private bool headersPresent;
120+
private IDictionary<string, object> headers;
121+
122+
private bool messageIdPresent;
123+
private string messageId;
126124

127-
public bool IsPriorityPresent()
128-
{
129-
throw new NotImplementedException();
130-
}
125+
private bool priorityPresent;
126+
private byte priority;
131127

132-
public bool IsReplyToPresent()
133-
{
134-
throw new NotImplementedException();
135-
}
128+
private bool replyToPresent;
129+
private string replyTo;
136130

137-
public bool IsTimestampPresent()
138-
{
139-
throw new NotImplementedException();
140-
}
131+
private bool timestampPresent;
132+
private AmqpTimestamp timestamp;
141133

142-
public bool IsTypePresent()
143-
{
144-
throw new NotImplementedException();
145-
}
134+
private bool typePresent;
135+
private string type;
146136

147-
public bool IsUserIdPresent()
148-
{
149-
throw new NotImplementedException();
150-
}
137+
private bool userIdPresent;
138+
private string userId;
151139

152-
public string AppId { get; set; }
153-
public string ClusterId { get; set; }
154-
public string ContentEncoding { get; set; }
155-
public string ContentType { get; set; }
156-
public string CorrelationId { get; set; }
157-
public byte DeliveryMode { get; set; }
158-
public string Expiration { get; set; }
159-
public IDictionary<string, object> Headers { get; set; }
160-
public string MessageId { get; set; }
140+
141+
142+
public string AppId { get => appId; set => SetValue(out appId, out appIdPresent, value); }
143+
public string ClusterId { get => clusterId; set => SetValue(out clusterId, out clusterIdPresent, value); }
144+
public string ContentEncoding { get => contentEncoding; set => SetValue(out contentEncoding, out contentEncodingPresent, value); }
145+
public string ContentType { get => contentType; set => SetValue(out contentType, out contentTypePresent, value); }
146+
public string CorrelationId { get => correlationId; set => SetValue(out correlationId, out correlationIdPresent, value); }
147+
public byte DeliveryMode { get => deliveryMode; set => SetValue(out deliveryMode, out deliveryModePresent, value); }
148+
public string Expiration { get => expiration; set => SetValue(out expiration, out expirationPresent, value); }
149+
public IDictionary<string, object> Headers { get => headers; set => SetValue(out headers, out headersPresent, value); }
150+
public string MessageId { get => messageId; set => SetValue(out messageId, out messageIdPresent, value); }
161151
public bool Persistent { get; set; }
162-
public byte Priority { get; set; }
163-
public string ReplyTo { get; set; }
152+
public byte Priority { get => priority; set => SetValue(out priority, out priorityPresent, value); }
153+
public string ReplyTo { get => replyTo; set => SetValue(out replyTo, out replyToPresent, value); }
164154
public PublicationAddress ReplyToAddress { get; set; }
165-
public AmqpTimestamp Timestamp { get; set; }
166-
public string Type { get; set; }
167-
public string UserId { get; set; }
155+
public AmqpTimestamp Timestamp { get => timestamp; set => SetValue(out timestamp, out timestampPresent, value); }
156+
public string Type { get => type; set => SetValue(out type, out typePresent, value); }
157+
public string UserId { get => userId; set => SetValue(out userId, out userIdPresent, value); }
158+
159+
160+
private static void SetValue<T>(out T field, out bool present, T value)
161+
{
162+
field = value;
163+
present = true;
164+
}
168165
}
169166
}

0 commit comments

Comments
 (0)