Writing an brokerless AMQP to MQTT adaptor

我的梦境 提交于 2021-02-11 18:22:53

问题


I want to implement an amqp to mqtt adapter, which would receive amqp messages, take their payload and publish it as mqtt messages to my mqtt broker. Therefore the adapter must be able to

  • listen on a port
  • confirm connect requests
  • receive amqp messages
  • acknowledge them
  • publish with mqtt

In my ecosystem I want to provide different protocols for incoming messages, but I want to run only one mqtt broker. I want to avoid any other broker. I read here that amqp "1.0 permits brokerless point-to-point communication". I guess that would be the right thing for my use case (Although amqp 0-9-1 would be nice).

I have trouble coming up with a approach for this. The rabbitmq client library seems to be only for client to broker communication.
I have also gone through the qpid repo. With their broker library I'm able to start an embedded broker in my own project like shown here. That's a nice gimmick, but is not what I need.
The mqtt stuff is no problem for me. What bothers me is the "wait for amqp messages" part.

I have been researching for a couple hours. Am I blind here? Or is it really that uncommon/complex?
I would really appreciate any advice on possible libraries or examples from you or the web.

Thank you.


回答1:


Depending on the language you are using you can use either the Qpid proton-c or proton-j protocol engine and implement your own in memory AMQP 1.0 server style component that can listen on a server socket and then accept incoming AMQP 1.0 connections and deal with the messages as you see fit. This does require you to have a pretty deep understanding of the protocol though and implement a fair bit of logic to deal with the variety of client behaviours you might see given the general flexibility of the AMQP 1.0 protocol.

You might save yourself a fair bit of effort by using one of the many multi protocol brokers like ActiveMQ Artemis or some such to handle all that for you. I think you might be able to leverage some of the higher level code in the proton C++ or C clients to help if you wanted to go your own way but it will still be a fair bit of work.



来源:https://stackoverflow.com/questions/60229831/writing-an-brokerless-amqp-to-mqtt-adaptor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!