Using Outbound Endpoints to Publish Data
This example shows how to use outbound endpoints in Mule. Outbound endpoints are useful for publishing data to a flow, application, or resource. This topic covers the following things:
-
How to build on an existing Mule flow in Mule Studio
-
How to get data from an HTTP inbound endpoint and output it to a file using an outbound endpoint
This example requires that you run through the earlier example Transforming Data in a Flow.
Building the Example
-
We are going to continue editing the example and add a File component to the flow. Drag the File endpoint from the palette to the canvas after the Echo component.
-
Double-click on the File endpoint to edit its properties.
-
In the "General" tab, give your flow a name and choose a path and name for the file that will be outputted. In the example below,
#[function:datestamp]
is a Mule expression which automatically appends the current date & time to a file named myfile.
Running the Example
-
Right-click on the flow in the project tree and select Run As… → Mule Application.
-
Next, open up a browser and go to http://localhost:8081/echo. You should see the following in your browser:
-
Now, go back to Mule Studio and check the logs - you will see that myfile#timestamp got created in the specified location with the output inside of it. Browse to the directory in your file explorer and open the file to see your output.
Summary
-
You sent an HTTP request via an inbound endpoint by going to http://localhost:8081/echo.
-
You added a File endpoint to your flow which demonstrated how Mule can take the information via the HTTP request and output it in different places (in this case, a file).