Skip to content

Question: How can I proxy the raw message without serializing it? #158

Answered by BEagle1984
nspyke asked this question in Q&A
Discussion options

You must be logged in to vote

There are multiple ways to achieve your goal.

1. Using the BinaryFileMessage

As the name suggests, this was meant to transfer binary files, but you can leverage it to publish any binary content including your UTF8 encoded string.

public class MyBinaryMessage : IBinaryFileMessage
{
    public MyBinaryMessage(byte[] content)
    {
        Content = new MemoryStream(content);
    }

    public Stream Content { get; }
}

public class MyService
{
    private readonly IPublisher _publisher;

    public MyService(IPublisher publisher)
    {
        _publisher = publisher;
    }

    public Task ProduceTestMessageAsync() => _publisher.PublishAsync(new MyBinaryMessage(Encoding.UTF8.GetBytes("your …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by nspyke
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #157 on March 04, 2022 17:29.