Skip to content

Commit

Permalink
fix for Value beingserialized
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalac committed Oct 12, 2023
1 parent c7dea6e commit 3aade50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace NServiceBus.AcceptanceTests.DataBus
{
using System;
using System.IO;
using System.Threading.Tasks;
using AcceptanceTesting;
using AcceptanceTesting.Customization;
using EndpointTemplates;
using NServiceBus.MessageMutator;
using NUnit.Framework;

public class When_sending_databus_properties_with_systemjsonserializer : NServiceBusAcceptanceTest
Expand Down Expand Up @@ -56,6 +58,7 @@ public Receiver()
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender");
builder.UseDataBus<FileShareDataBus, SystemJsonDataBusSerializer>().BasePath(basePath);
builder.UseSerialization<SystemJsonSerializer>();
builder.RegisterMessageMutator(new Mutator());
});
}

Expand All @@ -77,6 +80,18 @@ public Task Handle(MyMessageWithLargePayload messageWithLargePayload, IMessageHa
}
}

public class Mutator : IMutateIncomingTransportMessages
{
public Task MutateIncoming(MutateIncomingTransportMessageContext context)
{
if (context.Body.Length > PayloadSize)
{
throw new Exception("The message body is too large, which means the DataBus was not used to transfer the payload.");
}
return Task.CompletedTask;
}
}

public class MyMessageWithLargePayload : ICommand
{
public DataBusProperty<byte[]> Payload { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/NServiceBus.Core/DataBus/DataBusProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected DataBusProperty(SerializationInfo info, StreamingContext context)
/// <summary>
/// The value.
/// </summary>
[JsonIgnore]
public T Value => value;

/// <summary>
Expand Down

0 comments on commit 3aade50

Please sign in to comment.