The Python application code above generates messages that contain data with an orderId that increments once per second.
Here's a snippet from the Python script in app.js:
1dapr_port = os.getenv("DAPR_HTTP_PORT", 3500)2dapr_url = "http://localhost:{}/neworder".format(dapr_port)34n = 05while True:6 n += 17 message = {"data": {"orderId": n}}89 try:10 response = requests.post(dapr_url, json=message)11 except Exception as e:12 print(e)1314 time.sleep(1)
The Dapr sidecar for the Python application sends a POST request to the Dapr sidecar of the Node.js application using the Dapr service invocation API. Here's a breakdown of what happens;
The Python app sends a POST request to its sidecar at http://localhost:3500/v1.0/invoke/nodeapp/method/neworder. Note: http://localhost:3500 is the default listening port for Dapr.
The sidecar for the Python app invokes the nodeapp service through its own Dapr sidecar.
The Python app does not need to know the exact address or port of the Node.js service, it simply makes a request to its sidecar, which handles the routing.
Steps to Stream Python Application Logs:
The logs show the daprd container logs with a POST request made to /neworder endpoint.
Follow the same steps above to get the logs for the Node.js application. The logs show API calls made to the state store for persisting order data.
Here's what can be observed from the logs:
By analyzing these logs, we gained a deeper understanding of how Dapr's APIs such as the state management API and service invocation API work together to enable service-service communication and efficient management of application state.