{"id":28829495,"url":"https://github.com/ballerina-platform/module-ballerina-mqtt","last_synced_at":"2026-04-08T13:32:18.606Z","repository":{"id":183356511,"uuid":"670000501","full_name":"ballerina-platform/module-ballerina-mqtt","owner":"ballerina-platform","description":"Ballerina MQTT Module.","archived":false,"fork":false,"pushed_at":"2025-03-16T16:57:18.000Z","size":46158,"stargazers_count":106,"open_issues_count":0,"forks_count":11,"subscribers_count":53,"default_branch":"main","last_synced_at":"2025-06-19T05:16:17.229Z","etag":null,"topics":["ballerina","hacktoberfest","integration","iot","mqtt","pubsub","wso2"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ballerina-platform.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-24T04:37:02.000Z","updated_at":"2025-05-15T08:20:08.000Z","dependencies_parsed_at":"2023-10-03T12:43:40.354Z","dependency_job_id":"bebf5cf8-b600-49d1-9450-dcc78865e9db","html_url":"https://github.com/ballerina-platform/module-ballerina-mqtt","commit_stats":null,"previous_names":["ballerina-platform/module-ballerinax-mqtt"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ballerina-platform/module-ballerina-mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerina-mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerina-mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerina-mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerina-mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ballerina-platform","download_url":"https://codeload.github.com/ballerina-platform/module-ballerina-mqtt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerina-mqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31558381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ballerina","hacktoberfest","integration","iot","mqtt","pubsub","wso2"],"created_at":"2025-06-19T05:13:46.122Z","updated_at":"2026-04-08T13:32:18.589Z","avatar_url":"https://github.com/ballerina-platform.png","language":"Java","funding_links":[],"categories":["Clients","物联网"],"sub_categories":["Ballerina","文件同步"],"readme":"# Ballerina MQTT Library\n\n[![Build](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/build-timestamped-master.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/build-timestamped-master.yml)\n[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerina-mqtt/branch/master/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerina-mqtt)\n[![Trivy](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/trivy-scan.yml)\n[![GraalVM Check](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-mqtt/actions/workflows/build-with-bal-test-graalvm.yml)\n[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerina-mqtt.svg)](https://github.com/ballerina-platform/module-ballerina-mqtt/commits/master)\n\nThis Library provides an implementation to interact with MQTT servers via MQTT client and listener.\n\nMQTT is a lightweight, publish-subscribe, machine to machine network protocol for message queue/message queuing service.\n\n### Publisher and subscriber\n#### MQTT publisher\nA MQTT publisher is a MQTT client that publishes messages to the MQTT server. When working with a MQTT client, the first thing to do is to initialize the client.\nFor the publisher to work successfully, an active MQTT server should be available.\n\nThe code snippet given below initializes a publisher client with the basic configuration.\n```ballerina\nimport ballerina/mqtt;\nimport ballerina/uuid;\n \nmqtt:ClientConfiguration clientConfiguration = {\n    connectionConfig: {\n        username: \"ballerina\",\n        password: \"ballerinamqtt\"\n    }\n};\n\nmqtt:Client mqttClient = check new (mqtt:DEFAULT_URL, uuid:createType1AsString(), clientConfiguration); // A unique id needs to be provided as the client id\n```\nUsing the `publish` api of this client, messages can be sent to the MQTT server.\n```ballerina\ncheck mqttClient-\u003epublish(\"mqtt/test\", {payload: \"This is Ballerina MQTT client!!!\".toBytes()});\n```\n#### MQTT subscriber\nA MQTT subscriber is a client responsible for reading messages from one or more topics in the server. When working with a MQTT subscriber, the first thing to do is initialize the subscriber.\nFor the subscriber to work successfully, an active MQTT server should be available.\n\nThe code snippet given below initializes a subscriber with the basic configuration.\n```ballerina\nmqtt:ListenerConfiguration listenerConfiguration = {\n    connectionConfig: {\n        username: \"ballerina\",\n        password: \"ballerinamqtt\"\n    },\n    manualAcks: false   // When set to false, the MQTT acknowledgements are not sent automatically by the subscriber\n};\n\nmqtt:Listener mqttSubscriber = check new (mqtt:DEFAULT_URL, uuid:createType1AsString(), \"mqtt/test\", listenerConfiguration);\n```\nThis subscriber can be used in the `mqtt:Service` to listen to messages in `mqtt/test` topic.\n```ballerina\nservice on mqttSubscriber {\n    remote function onMessage(mqtt:Message message, mqtt:Caller caller) returns error? {\n        log:printInfo(check string:fromBytes(message.payload));\n        check caller-\u003ecomplete();\n    }\n\n    remote function onError(mqtt:Error err) returns error? {\n        log:printError(\"Error occured \", err);\n    }\n}\n```\nThe `mqtt:Caller` can be used to indicate that the application has completed processing the message by using `complete()` api.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fballerina-platform%2Fmodule-ballerina-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fballerina-platform%2Fmodule-ballerina-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fballerina-platform%2Fmodule-ballerina-mqtt/lists"}