Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Submit batch for messages of type string #776

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions src/ServiceBusExplorer/Forms/MessageForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ public partial class MessageForm : Form

static readonly List<string> Types = new List<string>
{
"Boolean",
"Byte",
"Int16",
"Int32",
"Int64",
"Single",
"Double",
"Decimal",
"Guid",
"DateTime",
"TimeSpan",
"String",
"Boolean",
"Byte",
"Int16",
"Int32",
"Int64",
"Single",
"Double",
"Decimal",
"Guid",
"DateTime",
"TimeSpan",
"String",
"Char",
"UInt64",
"UInt32",
Expand Down Expand Up @@ -221,7 +221,7 @@ public MessageForm(BrokeredMessage brokeredMessage, ServiceBusHelper serviceBusH
}
}

public MessageForm(QueueDescription queueDescription, QueueType queueType, BrokeredMessage brokeredMessage,
public MessageForm(QueueDescription queueDescription, QueueType queueType, BrokeredMessage brokeredMessage,
ServiceBusHelper serviceBusHelper, WriteToLogDelegate writeToLog) :
this(brokeredMessage, serviceBusHelper, writeToLog)
{
Expand Down Expand Up @@ -427,9 +427,23 @@ private async void btnSubmit_Click(object sender, EventArgs e)
MainForm.SingletonMainForm.UseAscii, out bodyType);

// For body type ByteArray cloning is not an option. When cloned, supplied body can be only of a string or stream types, but not byte array :(
outboundMessage = bodyType == BodyType.ByteArray ?
message.CloneWithByteArrayBodyType(messageText, messagesSplitContainer.Visible) :
message.Clone(message.GetBody<Stream>(), messagesSplitContainer.Visible);
switch (bodyType)
{
case BodyType.ByteArray:
outboundMessage = message.CloneWithByteArrayBodyType(messageText,
messagesSplitContainer.Visible);
break;

case BodyType.String:
outboundMessage = message.Clone(message.GetBody<string>(),
messagesSplitContainer.Visible);
break;

default:
outboundMessage = message.Clone(message.GetBody<Stream>(),
messagesSplitContainer.Visible);
break;
}
}

outboundMessage = serviceBusHelper.CreateMessageForApiReceiver(outboundMessage,
Expand Down Expand Up @@ -504,12 +518,12 @@ private async void btnSubmit_Click(object sender, EventArgs e)
var messageHandler = CreateDeadLetterMessageHandler();

var result = await messageHandler.MoveMessages(messageSender,
sequenceNumbers,
transferDLQ: queueType == QueueType.TransferDeadletter,
sequenceNumbers,
transferDLQ: queueType == QueueType.TransferDeadletter,
outboundMessages);

RemovedSequenceNumbers = result.DeletedSequenceNumbers;

stopwatch.Stop();

if (result.TimedOut)
Expand Down
Loading