Giter VIP home page Giter VIP logo

cloudeventify's Introduction

CloudEvents[Rebus|MassTransit|Dapr]

nuget codecov stryker build status

TL;DR

Just a serializer/deserializer for cloud events.

Use CloudEvents

Rebus + RabbitMQ

Configure.With(new EmptyActivator())
    .Transport(t => t.UseRabbitMqAsOneWayClient(_container.ConnectionString))
    .Serialization(s => s.UseCloudEvents()
        .AddWithCustomName<UserLoggedIn>("io.cloudevents.demo.user.loggedIn") // explicit
        .AddWithShortName<UserLoggedIn>()) // or with short name
    .Start();

Rebus + Azure Service Bus

Configure.With(activator)
    .Transport(t => t
        .UseNativeHeaders()
        .UseAzureServiceBus($"Endpoint={ConnectionString}", queue, new DefaultAzureCredential()))
    .Options(o => o
        .UseCustomTypeNameForTopicName())
    .Serialization(s => s.UseCloudEvents()
        .AddWithCustomName<UserLoggedIn>("io.cloudevents.demo.user.loggedIn")) // <-- all types _must_ be mapped explicitly, either by short name or custom name
    .Start();

Using custom source for one-way clients:

Configure.OneWayClient()
    .Transport(t => t
        .UseNativeHeaders()
        .UseAzureServiceBusAsOneWayClient($"Endpoint={ConnectionString}", new DefaultAzureCredential()))
    .Options(o => o
        .UseSenderAddress("my-custom-source")
        .UseCustomTypeNameForTopicName())
    .Serialization(s => s.UseCloudEvents()
        .AddWithCustomName<UserLoggedIn>("io.cloudevents.demo.user.loggedIn")) // <-- all types _must_ be mapped explicitly, either by short name or custom name
    .Start();

MassTransit + RabbitMQ

On bus level:

var bus = Bus.Factory
    .CreateUsingRabbitMq(cfg =>
    {
        cfg.UseCloudEvents()
    };

On a specific receive endpoint:

var bus = Bus.Factory
    .CreateUsingRabbitMq(cfg =>
    {
        cfg.ReceiveEndpoint("...", x =>
        {
            x.UseCloudEvents();
        }
    };

This adds a deserializer to support incoming messages using the default application/cloudevents+json content type and sets the serializer to wrap outgoing messages in a cloud event envelope.

Message Types

All (custom) types must be explicitly mapped, both for outgoing and incoming messages.

.UseCloudEvents()
    .WithTypes(t => t.Map<UserLoggedIn>("loggedIn"));

Specify the type attribute on the cloud events envelope. Used by the deserializer when you want to deserialize to a specific (sub)type.

Subject

The subject can be constructed using the instance of the outgoing message (currently not available for Rebus).

.UseCloudEvents()
    .WithTypes(t => t.Map<UserLoggedIn>("loggedIn"), map => map with { Subject = x => x.SomeProperty });

Limitations

The use of cloud events is only developed for and tested in a pure pub/sub broker setup. It is safe to assume that other patterns supported by MassTransit will not work since the information required for that is not conveyed.

Interoperable

In the integration tests, dapr is used as publisher and subscriber to test both the serializer and deserializer.

cloudeventify's People

Contributors

riezebosch avatar powdor42 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.