# # Copyright 2021 The Dapr Authors # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os import requests import time dapr_http_endpoint = os.getenv("DAPR_HTTP_ENDPOINT", "http://localhost:3500") dapr_url = "{}/neworder".format(dapr_http_endpoint) n = 0 while True: n += 1 message = {"data": {"orderId": n}} try: response = requests.post(dapr_url, json=message, timeout=5, headers = {"dapr-app-id": "nodeapp"} ) if not response.ok: print("HTTP %d => %s" % (response.status_code, response.content.decode("utf-8")), flush=True) except Exception as e: print(e, flush=True) time.sleep(1)