Skip to main content

SDK for the SmartOcean Platform Messaging Service

Project description

Messaging Service Client SDK

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

The messaging services rely on the MQTT Standard

This client SDK implementation utilises the 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:

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:

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sfisop_messaging_sdk-1.0.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sfisop_messaging_sdk-1.0.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file sfisop_messaging_sdk-1.0.3.tar.gz.

File metadata

  • Download URL: sfisop_messaging_sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.2.0

File hashes

Hashes for sfisop_messaging_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 af310ee8e8fc2073aa00059dd3eba099dcd023877b847938b158e4e671a54afd
MD5 6413d3dac66525929a96d0a9f69ceaa4
BLAKE2b-256 da049d93eeb340ab9b92b7ee6ca75b51392058c5b7cb173ac9829d4ea867a4b4

See more details on using hashes here.

File details

Details for the file sfisop_messaging_sdk-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sfisop_messaging_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f1fe83915350cc6070fbe7a78690a44e0fd2d2f14ccea7fb794e3687b76abb32
MD5 1937854410fddcac4a77e1b2df0f3a7d
BLAKE2b-256 09d2636c5a5c0243c5d6d071c2d45168ce8ba22c7ddceb5cd78f805443d6974a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page