Skip to content

Commit

Permalink
handle message without payload
Browse files Browse the repository at this point in the history
  • Loading branch information
GyroGearl00se committed Jul 20, 2024
1 parent b6c2b38 commit a83c0d8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Services/SolaceSubscribeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,17 @@ public void HandleMessage(object source, MessageEventArgs args, Action<string> m
{
using (IMessage message = args.Message)
{
string messageContent = Encoding.ASCII.GetString(message.BinaryAttachment);
messageHandler(messageContent);
string messageContent;

byte[] binaryAttachment = message.BinaryAttachment;
if (binaryAttachment != null && binaryAttachment.Length > 0)
{
messageContent = Encoding.UTF8.GetString(binaryAttachment);
messageHandler(messageContent);
} else
{
messageHandler("Message without payload");
}
}
}
catch (OperationErrorException ex)
Expand Down

0 comments on commit a83c0d8

Please sign in to comment.