Esempio n. 1
0
async def send_detectedObjects_message(message):
    try:
        output_message = Message(json.dumps(message["body"]))
        output_message.custom_properties = message["properties"]
        print("Sending detectedObjects message")
        await module_client.send_message_to_output(output_message, "detectedObjects")
        return 200
    except Exception as ex:
        print('Unexpected error from sending message: %s' % ex)
        return 400
Esempio n. 2
0
  async def send_json_message_to_output(self, payload, output_name, properties = {}):
    """
      Send a json payload to the module output. Routing of messages done in the deployment template
      
      Args:
        payload (dict): JSON serializable dictionary to be send
        output_name (str): The name of the output to publish the message to
        properties (:obj:´dict´, optional): Custom properties to add to the message. Will be added to message applicationProperties that can be queried for in message routing
    """
    message = Message(bytearray(json.dumps(payload), "utf8"), content_type = "application/json", content_encoding = "utf-8")
    message.custom_properties = properties

    await self.module_client.send_message_to_output(message, output_name)
Esempio n. 3
0
 async def send_test_message(i):
     time.sleep(1)
     print("sending message #" + str(i))
     msg = Message(
         "{ \"MGPID\": 48, \"MGPLabel\": \"X_tilt\", \"MGPName\": \"X_tilt\", \"Timestamp\": \"2020-08-12 17:57:02\", \"usec\": 492949, \"ParamVal\": \"88.000000\" }"
     )
     msg.message_id = uuid.uuid4()
     msg.correlation_id = "correlation-1234"
     msg.custom_properties = {
         "CustomerId": "1",
         "ProgramId": 2,
         "RegionId": 1964,
         "DeviceType": "4a",
         "MessageVersion": 23,
         "VIN": 3215,
         "ESN": 4232545,
         "DeviceSignalTimestamp": 7,
         "Provider": "Dana",
         "DeviceReleaseVersion": 1.0,
         "PlantId": 38
     }
     await device_client.send_message(msg)
     print("done sending message #" + str(i))