{"id":32168519,"url":"https://github.com/conduitframework/conduit_mqtt","last_synced_at":"2026-07-18T14:33:27.931Z","repository":{"id":48289936,"uuid":"150185956","full_name":"conduitframework/conduit_mqtt","owner":"conduitframework","description":"MQTT adapter for conduit framework https://github.com/conduitframework/conduit","archived":false,"fork":false,"pushed_at":"2021-08-03T05:20:24.000Z","size":94,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-05-21T12:56:43.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conduitframework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-25T00:36:33.000Z","updated_at":"2018-10-29T18:26:40.000Z","dependencies_parsed_at":"2022-07-24T22:16:53.302Z","dependency_job_id":null,"html_url":"https://github.com/conduitframework/conduit_mqtt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/conduitframework/conduit_mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduitframework%2Fconduit_mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduitframework%2Fconduit_mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduitframework%2Fconduit_mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduitframework%2Fconduit_mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conduitframework","download_url":"https://codeload.github.com/conduitframework/conduit_mqtt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduitframework%2Fconduit_mqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35621145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-18T02:00:07.223Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-21T15:54:46.656Z","updated_at":"2026-07-18T14:33:27.894Z","avatar_url":"https://github.com/conduitframework.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConduitMQTT\n\n[![CircleCI](https://img.shields.io/circleci/project/github/conduitframework/conduit_mqtt.svg?style=flat-square)](https://circleci.com/gh/conduitframework/conduit_mqtt)\n[![Coveralls](https://img.shields.io/coveralls/conduitframework/conduit_mqtt.svg?style=flat-square)](https://coveralls.io/github/conduitframework/conduit_mqtt)\n[![Hex.pm](https://img.shields.io/hexpm/v/conduit_mqtt.svg?style=flat-square)](https://hex.pm/packages/conduit_mqtt)\n[![Hex.pm](https://img.shields.io/hexpm/l/conduit_mqtt.svg?style=flat-square)](https://github.com/conduitframework/conduit_mqtt/blob/master/LICENSE.md)\n[![Hex.pm](https://img.shields.io/hexpm/dt/conduit_mqtt.svg?style=flat-square)](https://hex.pm/packages/conduit_mqtt)\n\nAn MQTT adapter for [Conduit](https://github.com/conduitframework/conduit).\n\n## Installation\n\nThis package can be installed as:\n\n  1. Add `conduit_mqtt` to your list of dependencies in `mix.exs`:\n\n```elixir\n    def deps do\n      [{:conduit_mqtt, \"~\u003e 0.1.0\"}]\n    end\n```\n\n  2. Ensure `conduit_mqtt` is started before your application:\n\n```elixir\n    def application do\n      [applications: [:conduit_mqtt]]\n    end\n```\n\n## Configuring the Adapter\n\n```elixir\n# config/config.exs\n\nconfig :my_app, MyApp.Broker,\n  adapter: ConduitMQTT, connection_opts: [server: {Tortoise.Transport.Tcp, host: 'localhost', port: 1883}]\n```\n\nFor the full set of connection_opts, see the docs for underlying library [Tortiose](https://hexdocs.pm/tortoise/connecting_to_a_mqtt_broker.html#connection-handler).\n\nNOTE: will and retain have not been tested. They may work by passing through on the opts. Let us know your use cases\nor submit a PR\n\n## Configuring Queues\n\nMQTT defines queues on use. Configuring subscribers and publishers is all that's needed.\n\n## Configuring a Subscriber\n\nInside an `incoming` block for a broker, you can define subscriptions to queues. Conduit will route messages on those\ntopics to your subscribers.\n\n``` elixir\ndefmodule MyApp.Broker do\n  incoming MyApp do\n    subscribe :my_subscriber, MySubscriber, from: \"rooms/+/temp\", qos: 1\n    subscribe :my_other_subscriber, MyOtherSubscriber,\n      from: \"rooms/#\", qos: 0\n  end\nend\n```\n\n### Options\n\n* `:from` - The topic filter to subscribe to.\n* `:qos` - The quality of service to use for the subscription - defaults to 0.\n\nSee [mqtt-overview](https://hexdocs.pm/tortoise/introduction.html#mqtt-overview) for more details on options.\n\n## Configuring a Publisher\n\nInside an `outgoing` block for a broker, you can define publications to exchanges. Conduit will deliver messages using the\noptions specified. You can override these options, by passing different options to your broker's `publish/3`.\n\n``` elixir\ndefmodule MyApp.Broker do\n  outgoing do\n    publish :something,\n      to: \"rooms/living-room/temp\",\n      qos: 1\n    publish :something_else,\n      to: \"rooms/dining-room/temp\",\n      qos: 1\n  end\nend\n```\n\n### Options\n\n* `:to` - The topic for the message. If the message already has it's destination set, this option will be ignored.\n* `:qos` - The quality of service for the publish defaults to 0.\n\n\n## Supporting Message Fields and Headers\n\nMQTT 3.1.1 and below do not support a mechanism for message headers.  In order to support Conduit's message headers and\nfields, you need to wrap them into your message body.  You can use\n[Conduit.Plug.Wrap](https://hexdocs.pm/conduit/Conduit.Plug.Wrap.html) and [Conduit.Plug.Unwrap](https://hexdocs.pm/conduit/Conduit.Plug.Unwrap.html) to help with that.\n\nExample pipelines might look as follows:\n\n```elixir\n   pipeline :serialize do\n     plug Conduit.Plug.Format, content_type: \"application/json\"\n     plug Conduit.Plug.Encode, encoding: \"aes256gcm\"\n     plug Conduit.Plug.Wrap\n     plug Conduit.Plug.Format, content_type: \"application/json\"\n   end\n```\n\nThe above formats the message body into json, encrypts it, wraps the headers, fields, and body into a map and then\nformats that into json for transport. Your pipeline could be simpler.\n\nAnd the reverse of the above pipeline:\n\n```elixir\n   pipeline :deserialize do\n     plug Conduit.Plug.Parse, content_type: \"application/json\"\n     plug Conduit.Plug.Unwrap\n     plug Conduit.Plug.Decode, encoding: \"aes256gcm\"\n     plug Conduit.Plug.Parse, content_type: \"application/json\"\n   end\n```\n\n## Local Testing with Docker\n\nverneMQ  docker command for development testing:\n\n``` bash\ndocker run -p 1883:1883 -e \"DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on\" -e \"DOCKER_VERNEMQ_log.console.level=debug\" -it erlio/docker-vernemq:1.5.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduitframework%2Fconduit_mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconduitframework%2Fconduit_mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduitframework%2Fconduit_mqtt/lists"}