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.2.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.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sfisop_messaging_sdk-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d48cbaf0d8d92c146cad206558da5d594900ff54a1b530c8acac36776a34d1b7
MD5 0bfa4736eaa48b09e7ea2f49b287f030
BLAKE2b-256 f3c34df033abb974f3bf733b8a67bf8016664f03eec0da950268673d027befb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sfisop_messaging_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f32f29b57ce14aada987400f276085bd3139fc428e381d8cdefaa15e63960b1
MD5 0af7c5e022fb6452f7cb7c9d18fb7669
BLAKE2b-256 e440205cc15dd1d4bb7810f5174b1b85a1b82930b54a9a9fa0c0c7e6c55bdb63

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