cloudevents / cloudevents/sdk-csharp

AMQP Rabbit

Open
#235 6 comments 0 reactions 1 assignee View on GitHub

@jskeet is already working on this.

Since Aug 17, 2022.

question
Dominant language
C#
Stars
334
Forks
88
Avg merge
7m
Merged PRs (30d)
2

Description

Hi,

Can you please provide an example/documentation how to dispatch and consume a message to and from rabbitMQ using ToAmqpMessage() ?

 var formatter = new JsonEventFormatter();

 var message = cloudEvent.ToAmqpMessage(ContentMode.Binary, formatter);

 var encoded = message.Encode();

//This message is then published to rabbit

Consumer

// Reading the message
Task<bool> MessageProcessor(BasicDeliverEventArgs eventArgs)
{
            var formatter = new JsonEventFormatter();
            var byteBuffer = new ByteBuffer(eventArgs.Body.ToArray(), 0, eventArgs.Body.Length, eventArgs.Body.Length);
            var message = Message.Decode(byteBuffer);
            var cloudEvent = message.ToCloudEvent(formatter);

// also tried
           var byteBuffer = JsonSerializer.Deserialize<ByteBuffer>(eventArgs.Body.ToArray());
            var message1 = Message.Decode(byteBuffer);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.