demessaging.messaging.producer module

Producer of messages submitted for the message broker.

Classes:

MessageProducer(pulsar_config[, topic])

Producer class to send requests to a registered backend module (topic)

class demessaging.messaging.producer.MessageProducer(pulsar_config: BaseMessagingConfig, topic: str | None = None)[source]

Bases: WebsocketConnection

Producer class to send requests to a registered backend module (topic)

Attributes:

RECONNECT_TIMEOUT_SLEEP

SOCKET_PING_INTERVAL

in_app

is_connected

Check if the websocket apps are connected.

out_app

Methods:

connect()

disconnect()

Disconnect in- and out-sockets.

on_in_message(ws_app, response)

Message handler for the incoming websocket connection.

on_out_message(ws_app, ack)

Message handler for the outgoing websocket connection.

send_request(request_msg)

Sends the given request to the backend module bound to the topic provided in the pulsar configuration.

setup_subscription()

wait_for_connection([timeout])

Wait until the websockets are connected

RECONNECT_TIMEOUT_SLEEP = 5
SOCKET_PING_INTERVAL = 60
connect()[source]
disconnect()[source]

Disconnect in- and out-sockets.

in_app: WebSocketApp
property is_connected: bool

Check if the websocket apps are connected.

on_in_message(ws_app: WebSocketApp, response)[source]

Message handler for the incoming websocket connection.

on_out_message(ws_app: WebSocketApp, ack)[source]

Message handler for the outgoing websocket connection.

out_app: WebSocketApp
response_topic: str
async send_request(request_msg) Any[source]

Sends the given request to the backend module bound to the topic provided in the pulsar configuration. In order to increase re-usability the destination topic can be overridden with the optional topic argument.

Parameters:
  • request_msg – dictionary providing a ‘property’ dictionary, a payload string, or both

  • topic – overrides the used topic for this request

Returns:

received response from the backend module

setup_subscription()[source]
subscription_name: str
wait_for_connection(timeout=10)[source]

Wait until the websockets are connected