Skip to content

Commit dc395c3

Browse files
committed
Leaving Content-Type only
1 parent 9cb6901 commit dc395c3

5 files changed

Lines changed: 26 additions & 116 deletions

File tree

src/NServiceBus.Transport.RabbitMQ.Tests/MessageConverterTests.cs

Lines changed: 24 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -37,115 +37,61 @@ class TestingBasicProperties : IBasicProperties
3737

3838
DeliveryModes IReadOnlyBasicProperties.DeliveryMode => throw new NotImplementedException();
3939

40-
public void ClearAppId()
41-
{
42-
throw new NotSupportedException();
43-
}
40+
public void ClearAppId() => throw new NotSupportedException();
4441

45-
public void ClearClusterId()
46-
{
47-
throw new NotSupportedException();
48-
}
42+
public void ClearClusterId() => throw new NotSupportedException();
4943

50-
public void ClearContentEncoding()
51-
{
52-
throw new NotSupportedException();
53-
}
44+
public void ClearContentEncoding() => throw new NotSupportedException();
5445

55-
public void ClearContentType()
56-
{
57-
throw new NotSupportedException();
58-
}
46+
public void ClearContentType() => throw new NotSupportedException();
5947

60-
public void ClearCorrelationId()
61-
{
62-
throw new NotSupportedException();
63-
}
48+
public void ClearCorrelationId() => throw new NotSupportedException();
6449

65-
public void ClearDeliveryMode()
66-
{
67-
throw new NotSupportedException();
68-
}
50+
public void ClearDeliveryMode() => throw new NotSupportedException();
6951

70-
public void ClearExpiration()
71-
{
72-
throw new NotSupportedException();
73-
}
52+
public void ClearExpiration() => throw new NotSupportedException();
7453

75-
public void ClearHeaders()
76-
{
77-
throw new NotSupportedException();
78-
}
54+
public void ClearHeaders() => throw new NotSupportedException();
7955

80-
public void ClearMessageId()
81-
{
82-
throw new NotSupportedException();
83-
}
56+
public void ClearMessageId() => throw new NotSupportedException();
8457

85-
public void ClearPriority()
86-
{
87-
throw new NotSupportedException();
88-
}
58+
public void ClearPriority() => throw new NotSupportedException();
8959

90-
public void ClearReplyTo()
91-
{
92-
throw new NotSupportedException();
93-
}
60+
public void ClearReplyTo() => throw new NotSupportedException();
9461

95-
public void ClearTimestamp()
96-
{
97-
throw new NotSupportedException();
98-
}
62+
public void ClearTimestamp() => throw new NotSupportedException();
9963

100-
public void ClearType()
101-
{
102-
throw new NotSupportedException();
103-
}
64+
public void ClearType() => throw new NotSupportedException();
10465

105-
public void ClearUserId()
106-
{
107-
throw new NotSupportedException();
108-
}
66+
public void ClearUserId() => throw new NotSupportedException();
10967

110-
public bool IsAppIdPresent() => AppId != null;
68+
public bool IsAppIdPresent() => throw new NotSupportedException();
11169

112-
public bool IsClusterIdPresent()
113-
{
114-
throw new NotSupportedException();
115-
}
70+
public bool IsClusterIdPresent() => throw new NotSupportedException();
11671

117-
public bool IsContentEncodingPresent() => ContentEncoding != null;
72+
public bool IsContentEncodingPresent() => throw new NotSupportedException();
11873

11974
public bool IsContentTypePresent() => ContentType != null;
12075

12176
public bool IsCorrelationIdPresent() => !string.IsNullOrEmpty(CorrelationId);
12277

12378
public bool IsDeliveryModePresent() => DeliveryMode != 0;
12479

125-
public bool IsExpirationPresent() => Expiration != null;
80+
public bool IsExpirationPresent() => throw new NotSupportedException();
12681

127-
public bool IsHeadersPresent()
128-
{
129-
throw new NotSupportedException();
130-
}
82+
public bool IsHeadersPresent() => throw new NotSupportedException();
13183

13284
public bool IsMessageIdPresent() => !string.IsNullOrEmpty(MessageId);
13385

134-
public bool IsPriorityPresent()
135-
{
136-
throw new NotSupportedException();
137-
}
86+
public bool IsPriorityPresent() => throw new NotSupportedException();
13887

13988
public bool IsReplyToPresent() => !string.IsNullOrEmpty(ReplyTo);
14089

141-
public bool IsTimestampPresent()
142-
{
143-
throw new NotSupportedException();
144-
}
90+
public bool IsTimestampPresent() => throw new NotSupportedException();
14591

14692
public bool IsTypePresent() => !string.IsNullOrEmpty(Type);
14793

148-
public bool IsUserIdPresent() => UserId != null;
94+
public bool IsUserIdPresent() => throw new NotSupportedException();
14995
}
15096

15197
MessageConverter converter = new MessageConverter(MessageConverter.DefaultMessageIdStrategy);
@@ -388,13 +334,12 @@ public void TestCanHandleTablesListHeader()
388334
}
389335

390336
[Test]
391-
public void Should_handle_basic_properties()
337+
public void Should_handle_content_type()
392338
{
393339
var basicProperties = new TestingBasicProperties
394340
{
395341
MessageId = "Blah",
396-
ContentType = "content_type",
397-
ContentEncoding = "content_encoding"
342+
ContentType = "content_type"
398343
};
399344

400345
var message = new BasicDeliverEventArgs(default, default, default, default, default, basicProperties, default);
@@ -407,7 +352,6 @@ public void Should_handle_basic_properties()
407352
Assert.That(messageId, Is.Not.Null);
408353
Assert.That(headers, Is.Not.Null);
409354
Assert.That(headers[NServiceBus.Headers.ContentType], Is.EqualTo(basicProperties.ContentType));
410-
Assert.That(headers[PropertiesToHeaderMapping.ContentEncoding], Is.EqualTo(basicProperties.ContentEncoding));
411355
});
412356
}
413357
}

src/NServiceBus.Transport.RabbitMQ.Tests/When_sending_a_message_over_rabbitmq.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ public Task Should_transmit_all_transportMessage_headers()
110110
});
111111
}
112112

113-
[Test]
114-
public Task Should_set_the_content_encoding()
115-
{
116-
return Verify(new OutgoingMessageBuilder().WithHeader(PropertiesToHeaderMapping.ContentEncoding, "content-encoding"), received => Assert.That(received.BasicProperties.ContentEncoding, Is.EqualTo("content-encoding")));
117-
}
118-
119113
async Task Verify(OutgoingMessageBuilder builder, Action<IncomingMessage, BasicDeliverEventArgs> assertion, CancellationToken cancellationToken = default)
120114
{
121115
var operations = builder.SendTo(QueueToReceiveOn).Build();

src/NServiceBus.Transport.RabbitMQ/Configuration/PropertiesToHeaderMapping.cs

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

src/NServiceBus.Transport.RabbitMQ/Receiving/MessageConverter.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public Dictionary<string, string> RetrieveHeaders(BasicDeliverEventArgs message)
4444
messageHeaders.Remove(Constants.PublishSequenceNumberHeader);
4545
}
4646

47-
// Leaving space for ReplyTo, CorrelationId, DeliveryMode, EnclosedMessageTypes conditionally
47+
// Leaving space for ReplyTo, CorrelationId, DeliveryMode, EnclosedMessageTypes, ContentType conditionally
4848
// added below. This is a bit cumbersome and need to be changed when things are conditionally added below
4949
// but it prevents the header dictionary from growing and relocating which creates quite a bit of
5050
// memory allocations and eats up CPU cycles.
51-
const int extraCapacity = 4;
51+
const int extraCapacity = 5;
5252
var deserializedHeaders = DeserializeHeaders(messageHeaders, extraCapacity);
5353

5454
if (properties.IsReplyToPresent())
@@ -82,16 +82,6 @@ public Dictionary<string, string> RetrieveHeaders(BasicDeliverEventArgs message)
8282
deserializedHeaders[Headers.ContentType] = properties.ContentType;
8383
}
8484

85-
if (properties.IsAppIdPresent())
86-
{
87-
deserializedHeaders[PropertiesToHeaderMapping.AppId] = properties.AppId;
88-
}
89-
90-
if (properties.IsContentEncodingPresent())
91-
{
92-
deserializedHeaders[PropertiesToHeaderMapping.ContentEncoding] = properties.ContentEncoding;
93-
}
94-
9585
//These headers need to be removed so that they won't be copied to an outgoing message if this message gets forwarded
9686
//They can't be removed before deserialization because the value is used by the message pump
9787
deserializedHeaders.Remove("x-delivery-count");

src/NServiceBus.Transport.RabbitMQ/Sending/BasicPropertiesExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,6 @@ public static void Fill(this IBasicProperties properties, OutgoingMessage messag
7070
{
7171
properties.ReplyTo = replyToAddress;
7272
}
73-
74-
if (messageHeaders.TryGetValue(PropertiesToHeaderMapping.AppId, out var appId) && appId != null)
75-
{
76-
properties.AppId = appId;
77-
}
78-
79-
if (messageHeaders.TryGetValue(PropertiesToHeaderMapping.ContentEncoding, out var contentEncoding) && contentEncoding != null)
80-
{
81-
properties.ContentEncoding = contentEncoding;
82-
}
8373
}
8474

8575
static bool CalculateDelay(DispatchProperties dispatchProperties, out long delay)

0 commit comments

Comments
 (0)