与非.NET服务的MassTransit互操作性 [英] MassTransit Interoperability with non-.NET services

查看:77
本文介绍了与非.NET服务的MassTransit互操作性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用MassTransit,非常喜欢它.但是,默认情况下,它会使用特定于MassTransit的JSON包装所有RabbitMQ负载/消息.这使得很难与非.NET服务交换消息.我知道JSON可以用任何语言解析,但是MassTransit是仅用于.NET的东西,在我的非.NET服务中,我希望避免添加特殊逻辑来处理MassTransit生成的消息.

是否可以使用不通过"MessageEnvelope"接口的MassTransit序列化JSON消息,以与非MassTransit服务建立更好的互操作性?还是这样做会破坏大多数/全部的MassTransit功能?

解决方案

它是中所述的文档.

由于消息的格式是预先定义的,因此您将无法避免使用某些特殊逻辑来消耗MT消息.

这是一条最小的消息:

{
    "destinationAddress": "rabbitmq://localhost/input_queue",
    "headers": {},
    "message": {
        "value": "Some Value",
        "customerId": 27
    },
    "messageType": [
        "urn:message:MassTransit.Tests:ValueMessage"
    ]
}

I have been using MassTransit and really like it. However, by default, it wraps all RabbitMQ payloads/messages with some JSON specific to MassTransit. This makes it difficult to exchange messages with non-.NET services. I know that JSON can be parsed by any language, but MassTransit is a .NET-only thing, and in my non-.NET services, I'd like to avoid having to add special logic to handle messages generated by MassTransit.

Is it possible to serialize JSON messages using MassTransit that don't go through the "MessageEnvelope" interface to establish better interoperability with non-MassTransit services? Or would doing this break most/all the MassTransit functionality?

解决方案

It is described in the documentation.

You won't be able to avoid having some special logic to consume MT messages since the format of messages is pre-defined.

This is a minimal message:

{
    "destinationAddress": "rabbitmq://localhost/input_queue",
    "headers": {},
    "message": {
        "value": "Some Value",
        "customerId": 27
    },
    "messageType": [
        "urn:message:MassTransit.Tests:ValueMessage"
    ]
}

这篇关于与非.NET服务的MassTransit互操作性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆