Skip to main content

Messaging Communication Layer for Microservices Architecture

Project description

Messaging Layer for Microservices

     _ _          _       _                     
    | (_)        | |     (_)                    
  __| |_ ___  ___| | __ _ _ _ __ ___   ___ _ __ 
 / _` | / __|/ __| |/ _` | | '_ ` _ \ / _ \ '__|
| (_| | \__ \ (__| | (_| | | | | | | |  __/ |   
 \__,_|_|___/\___|_|\__,_|_|_| |_| |_|\___|_|   

This service is in his early age. DO NOT USE in production or if you want to, please be aware you are going to use a piece of code which probably will be changed or improved ( and not necessarily in this order) soon and very often. You have been warned! This service requires at least another service listening to a few KAFKA topics.

Service description

This service provides microservices with an universal communication layer based on KAFKA messages. It provides two kind of Producer. One based on KAFKA and the other one based on the Confluent KAFKA version.

Required ENV variables

  • brokers=mybroker1:9093,mybroker2:9093,mybroker3:9093
  • monitoring_topic=tcservicesmonitor

If you are using AVRO you must have

  • schema_registry=https://my_avro_schema_registry:8081

How to use it

PLAIN TEXT connection

from messaging_middleware.avro_communication_layer.Producer import Producer
producer = Producer(bootstrap_servers="your broker list here",
                                 schema_reqistry_url="your schema registry here",topic='mytopic')


producer.produce_message(
            value={your json message here},
            key={your key schema here}, callback=my_callback_function)

SSL configuration

in order to connect to brokers using the SSL protocol, we need to pass the following kwargs to consumers/producers configuration

from messaging_middleware.avro_communication_layer.Consumer import Consumer as AvroConsumer
from messaging_middleware.avro_communication_layer.Producer import Producer as AvroProducer

if __name__ == "__main__":
    c = AvroConsumer(
        bootstrap_servers="sslbroker:29080",
        security_protocoll='ssl', consumer_topic='my-topic')

    p = AvroProducer(
        bootstrap_servers="sslbroker:29080",
        security_protocoll='ssl', topic='my-topic')

Integrated Logging System

By default, the Logger is connected to the following ENV variables

  • brokers=mybroker:202021,mybroker2:202019
  • schema_registry="https://sksk:8081"
  • monitoring_topic=tcservicesmonitor
from messaging_middleware.utils.logger import Logger

logger = Logger(ssl=1) 
logger = Logger()  # no ssl

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

microservices_messaging_layer-1.0.17.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

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