sfisop-messaging-sdk


Namesfisop-messaging-sdk JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummarySDK for the SmartOcean Platform Messaging Service
upload_time2025-02-06 09:39:36
maintainerNone
docs_urlNone
authorThe SmartOcean Consortium
requires_python<4.0.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Messaging Service Client SDK

Client library for accessing the realtime messaging services of the SmartOcean platform.

The messaging services rely on the [MQTT Standard](https://mqtt.org/) 

This client SDK implementation utilises the [Paho MQTT](https://pypi.org/project/paho-mqtt/) library. The Paho MQTT library may also be used directly to access the messaging services in case more advanced use is required.

## Credentials

Credentials for accessing the messaging service being consumed must be placed in a `.env` file with the following content

```
BROKER_USERNAME=<username>
BROKER_PASSWORD=<password>
```

## Configuration

Broker configuration information must be provided in a yaml configuration file with the following format:

```
BROKER_HOST: 
BROKER_PORT: 
BROKER_TOPIC: 
TOPIC_QOS: 
CLIENT_ID: 
```
The name of the configuration file in the example below is to be provided as a command-line argument when running the Python application.

## Sample Subscriber

A sample implementation accessing the messaging service as a subscriber:

```python

import sfisop.messaging_sdk.subscriber as mqtt_subscriber
import sfisop.messaging_sdk.configuration as mqtt_configuration

import logging

logging.basicConfig(filename='subscriber_client.log',
                    format="%(asctime)s[%(levelname)s]:%(message)s", encoding='utf-8',
                    level=logging.DEBUG)

logging.info("MQTT Subscriber Client module")


class DataConsumer(mqtt_subscriber.SubscriberClient):

    def __init__(self, config_file : str):

        mqtt_client_config = mqtt_configuration.ClientConfiguration(config_file)

        super().__init__(mqtt_client_config)

    def process_one(self, in_message):

        logging.info(f'Data Consumer process_one: {in_message}')


if __name__ == '__main__':

    config_file = mqtt_configuration.get_config_file()

    data_consumer = DataConsumer(config_file)

    data_consumer.run()
```

## Sample Publisher

A sample implementation accessing the messaging service as a publisher:

```python
from sfisop.messaging_sdk.publisher import PublisherClient
from sfisop.messaging_sdk.configuration import ClientConfiguration, get_config_file

if __name__ == '__main__':

    config_file = get_config_file()

    config = ClientConfiguration(config_file)

    publisher_client = PublisherClient(config)

    publisher_client.publish_one("Hello World Publisher Client")
```



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sfisop-messaging-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "The SmartOcean Consortium",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/da/04/9d93eeb340ab9b92b7ee6ca75b51392058c5b7cb173ac9829d4ea867a4b4/sfisop_messaging_sdk-1.0.3.tar.gz",
    "platform": null,
    "description": "# Messaging Service Client SDK\n\nClient library for accessing the realtime messaging services of the SmartOcean platform.\n\nThe messaging services rely on the [MQTT Standard](https://mqtt.org/) \n\nThis client SDK implementation utilises the [Paho MQTT](https://pypi.org/project/paho-mqtt/) library. The Paho MQTT library may also be used directly to access the messaging services in case more advanced use is required.\n\n## Credentials\n\nCredentials for accessing the messaging service being consumed must be placed in a `.env` file with the following content\n\n```\nBROKER_USERNAME=<username>\nBROKER_PASSWORD=<password>\n```\n\n## Configuration\n\nBroker configuration information must be provided in a yaml configuration file with the following format:\n\n```\nBROKER_HOST: \nBROKER_PORT: \nBROKER_TOPIC: \nTOPIC_QOS: \nCLIENT_ID: \n```\nThe name of the configuration file in the example below is to be provided as a command-line argument when running the Python application.\n\n## Sample Subscriber\n\nA sample implementation accessing the messaging service as a subscriber:\n\n```python\n\nimport sfisop.messaging_sdk.subscriber as mqtt_subscriber\nimport sfisop.messaging_sdk.configuration as mqtt_configuration\n\nimport logging\n\nlogging.basicConfig(filename='subscriber_client.log',\n                    format=\"%(asctime)s[%(levelname)s]:%(message)s\", encoding='utf-8',\n                    level=logging.DEBUG)\n\nlogging.info(\"MQTT Subscriber Client module\")\n\n\nclass DataConsumer(mqtt_subscriber.SubscriberClient):\n\n    def __init__(self, config_file : str):\n\n        mqtt_client_config = mqtt_configuration.ClientConfiguration(config_file)\n\n        super().__init__(mqtt_client_config)\n\n    def process_one(self, in_message):\n\n        logging.info(f'Data Consumer process_one: {in_message}')\n\n\nif __name__ == '__main__':\n\n    config_file = mqtt_configuration.get_config_file()\n\n    data_consumer = DataConsumer(config_file)\n\n    data_consumer.run()\n```\n\n## Sample Publisher\n\nA sample implementation accessing the messaging service as a publisher:\n\n```python\nfrom sfisop.messaging_sdk.publisher import PublisherClient\nfrom sfisop.messaging_sdk.configuration import ClientConfiguration, get_config_file\n\nif __name__ == '__main__':\n\n    config_file = get_config_file()\n\n    config = ClientConfiguration(config_file)\n\n    publisher_client = PublisherClient(config)\n\n    publisher_client.publish_one(\"Hello World Publisher Client\")\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "SDK for the SmartOcean Platform Messaging Service",
    "version": "1.0.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09d2636c5a5c0243c5d6d071c2d45168ce8ba22c7ddceb5cd78f805443d6974a",
                "md5": "1937854410fddcac4a77e1b2df0f3a7d",
                "sha256": "f1fe83915350cc6070fbe7a78690a44e0fd2d2f14ccea7fb794e3687b76abb32"
            },
            "downloads": -1,
            "filename": "sfisop_messaging_sdk-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1937854410fddcac4a77e1b2df0f3a7d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.9",
            "size": 7345,
            "upload_time": "2025-02-06T09:39:35",
            "upload_time_iso_8601": "2025-02-06T09:39:35.037980Z",
            "url": "https://files.pythonhosted.org/packages/09/d2/636c5a5c0243c5d6d071c2d45168ce8ba22c7ddceb5cd78f805443d6974a/sfisop_messaging_sdk-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da049d93eeb340ab9b92b7ee6ca75b51392058c5b7cb173ac9829d4ea867a4b4",
                "md5": "6413d3dac66525929a96d0a9f69ceaa4",
                "sha256": "af310ee8e8fc2073aa00059dd3eba099dcd023877b847938b158e4e671a54afd"
            },
            "downloads": -1,
            "filename": "sfisop_messaging_sdk-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "6413d3dac66525929a96d0a9f69ceaa4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.9",
            "size": 4774,
            "upload_time": "2025-02-06T09:39:36",
            "upload_time_iso_8601": "2025-02-06T09:39:36.714149Z",
            "url": "https://files.pythonhosted.org/packages/da/04/9d93eeb340ab9b92b7ee6ca75b51392058c5b7cb173ac9829d4ea867a4b4/sfisop_messaging_sdk-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-06 09:39:36",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sfisop-messaging-sdk"
}
        
Elapsed time: 0.53648s