Here are the patterns which are highly used
- To stream all the data from WebSockets
- To stream all the data to the clients from an HTTP request
- To stream only data which is requested by the client
This is the overall flow after creating the API
Steps to stream the data from HTTP Request using WebSockets connector in Mule 4
Step 1: Configuring On New Inbound Message (WS Listener)Step 2: Scheduler configuration as below
Step 3: Request configuration as below
- Request host: api.coincap.io
- Request port: 80
- Request Path: /v2/assets/bitcoin
Step 4: Configuring Broadcast component in Mule 4 WebSocket connector
Testing WebSockets API using Postwoman
- Open www.postwoman.io/realtime
- Provide the URL (ws://localhost:8082/ws/wsdata). Click on connect
- You can see that data is streaming to your browser as below
Find the latest MuleSoft(Mule 4) Articles on DataWeave, Anypoint Studio, Anypoint Platform, and Runtime Manager. Our articles also include frequently asked Mule4 Interview questions and answers. Please comment below for any queries or free article submissions.
0 Comments