system.eventstream.publishEvent
This function is used in Python Scripting.
Description​
Publishes a message to a Gateway Event Source. You can publish a message to the local Gateway, or a remote Gateway.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.eventstream.publishEvent(project, path, message, acknowledge, [gatewayName])
Parameters​
| Type | Parameter | Description |
|---|---|---|
| String | project | The project the event stream(s) belong to. |
| String | path | The path to the event stream resource. |
| String | message | The string message to send. |
| Boolean | acknowledge | If True, further messages will be blocked until the receiving Gateway Event Listener source finishes processing the current message. If False, further messages will not be blocked while waiting for a response from the Gateway Event Listener source. |
| String | gatewayName | The Gateway Name of the remote Gateway you want to send the message to. Not specifying a remote Gateway or using None will send the message to the specified event stream path and project on the local Gateway. [Optional] |
Returns​
PyDictionary - A dictionary of key and value status pairs resulting from publishing the specified event stream. Keys returned include:
- errorMessage
- stage
- status
Scope​
Gateway
Code Examples​
Example #1
# Sends the specified message to the "listener" event stream located within the "event-stream" project.
system.eventstream.publishEvent("event-stream", "listener", "I am a message!", True)
Example #2
# Parses the message payload as a JSON object using the jsonEncode function, after which publishEvent will then send the message to the project called "myProject".
project = "myProject"
path = "myEventStream"
rawMessage = {'value': self.getSibling("TextField").props.text}
acknowledge = True
gatewayId = None
message = system.util.jsonEncode(rawMessage)
system.eventstream.publishEvent(project, path, message, acknowledge, gatewayName)