2019-02-11 20:26
浏览 244

使用Go Micro从一个经纪人消费并生产到另一个经纪人

I am trying to write a microservice using the Go Micro framework which is going to consume from a RabbitMQ broker and Write to another.

Go Micro has a RabbitMQ plugin however it seems that if one wants to use the Go Micro abstractions (Such as micro.RegisterSubscriber), one has to rely on a lot of global states internal to the library. I ended up setting up a consumer using micro.RegisterSubscriber and then manually creating a separate broker with care to not use any internal global state (Such as default exchange) and then call broker.Publish within the consumer function which meant I had to Marshal the message manually before shipping it.

Is this not a supported pattern in Go Micro? Is there any better way of going about doing something like this?

I should mention that the main reason for choosing Go Micro in this particular case is because it seems to have a reliable RabbitMQ abstraction with reconnect support which seems to be hard to come by in Go, not necessarily because I needed RPC support in this one case.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用Go Micro框架编写微服务,该框架将从RabbitMQ代理中使用并写入 </ p>

Go Micro有RabbitMQ插件,但是似乎如果要使用Go Micro抽象(例如, micro.RegisterSubscriber </ code>),则必须 依赖于图书馆内部的许多全局状态。 我最终使用 micro.RegisterSubscriber </ code>设置了一个使用者,然后手动创建一个单独的代理,小心不要使用任何内部全局状态(例如默认交换),然后调用 broker.Publish < 使用者函数中的/ code>,这意味着我必须在发送消息之前先将其封送。</ p>

这是Go Micro不支持的模式吗? </ p>

我应该提到在这种特殊情况下选择Go Micro的主要原因是因为它似乎具有可靠的RabbitMQ抽象 重新连接支持,这在Go中似乎很难获得,不一定是因为在这种情况下我需要RPC支持。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题