demessaging.messaging.producer module
Producer of messages submitted for the message broker.
Classes:
|
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:
Check if the websocket apps are connected.
Methods:
connect
()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.
wait_for_connection
([timeout])Wait until the websockets are connected
- RECONNECT_TIMEOUT_SLEEP = 5
- SOCKET_PING_INTERVAL = 60
- in_app: WebSocketApp
- 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
- 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