Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

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.

What you will Learn

  • 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

Build it now!

15 minutes

Prerequisites

This example requires that you run through the earlier example Transforming Data in a Flow.

Building the Example

  1. 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.

    studioFlowShouldLookLike-1

  2. Double-click on the File endpoint to edit its properties.

  3. 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,

    
                 
              
    1
    
    #[function:datestamp]

is a Mule expression which automatically appends the current date & time to a file named myfile.

studioConfigureFileEndpoint

Running the Example

  1. Right-click on the flow in the project tree and select Run As…​ → Mule Application.

    studioRunApplication

  2. Next, open up a browser and go to http://localhost:8081/echo. You should see the following in your browser:

    image

  3. 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.

    studioFileOutput

What Just Happened?

  • 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).