Studio Visual Editor
-
Drag an HTTP endpoint onto the canvas
-
Set its Path to authenticate
.
Create a Connector Configuration element, set its host to localhost and its port to 8081
-
Add a Google Contacts connector to the flow, then set its Operation to Authorize.
-
Create a Google Contacts Global Element, then configure its Consumer Key and Consumer secret.
-
Create a new flow with a new HTTP endpoint.
-
Set its Path to get_contacts
.
-
Add a new Google Contacts connector in the new flow.
-
Set its Operation to Get Contacts
and its Fetch Size to 50
.
-
Add a Foreach scope after the Google Contacts connector.
Add a Logger inside the Foreach scope.
+
image::autopaging-flow.png[autopaging+flow]
When a message reaches the Google Contacts connector, the Logger outputs a separate message for each object. If there are more than 50 objects, Mule paginates the output.
XML Editor
-
Create a google-contacts Global Element, then define its Consumer Key and Consumer secret.
<google-contacts:config-with-oauth name="Google_Contacts" consumerKey="" consumerSecret="" doc:name="Google Contacts" applicationName="Mule-GoogleContactsConnector">
<google-contacts:oauth-callback-config domain="localhost" path="auth" remotePort="8081"/>
</google-contacts:config-with-oauth>
-
Create an HTTP connector and set the value of its Path to authenticate
.
<http:listener config-ref="listener-config" path="authenticate" doc:name="HTTP Connector"/>
-
Outside the flow, create a configuration element that matches the name referenced by the connector. Set the host to localhost and the port to 8081.
<http:listener-config name="listener-config" host="localhost" port="8081"/>
-
Add a Google Contacts connector setting its operation to authorize.
<google-contacts:authorize config-ref="Google_Contacts" doc:name="Google Contacts"/>
-
Create a new flow with a new HTTP endpoint. Set the value of its Path to get_contacts
, and reference the same configuration element as the other connector.
<http:listener config-ref="listener-config" path="get_contacts" doc:name="HTTP Connector"/>
-
Add a new Google Contacts connector in the new flow setting its operation to get-contacts
and fetchSize to 50
.
<google-contacts:get-contacts config-ref="Google_Contacts" doc:name="Google Contacts" fetchSize="50"/>
-
After the Google Contacts connector, add a Foreach to the flow, then add a Logger as a child element inside Foreach element.
<foreach doc:name="For Each">
<logger message="#[message.payload.getEmailAddresses()]" level="INFO" doc:name="Logger"/>
</foreach>
When a message reaches the Google Contacts connector, the Logger outputs a separate message for each object. If there are more than 50 objects, Mule paginates the output. See below for a Complete Example.