Skip to content

Instantly share code, notes, and snippets.

wrapper.java.additional.4=-Denv_name=prod
wrapper.java.additional.5=-Dmule.password=muleftw
<context:property-placeholder properties-ref="MuleMeetZuul"/>
<spring:beans>
<zuul:properties id="MuleMeetZuul" config="AcmeProperties" host="localhost" port="8080"
context="/zuul-web-1.5" environment="#{environment['env_name']}">
<zuul:file-store/>
<zuul:pbe-decryptor password="#{environment['mule.password']}" algorithm="PBEWITHSHA256AND128BITAES-CBC-BC"/>
</zuul:properties>
</spring:beans>
<mule xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:zuul="http://www.devnull.org/schema/zuul-spring-client"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.devnull.org/schema/zuul-spring-client http://www.devnull.org/schema/zuul-spring-client.xsd">
acme.jdbc.host=acmedb
acme.jdbc.port=3306
acme.jdbc.database=acmeProducts
acme.jdbc.user=WileECoyote
acme.jdbc.password=GeeWhizz
<scripting:component>
<scripting:script engine="groovy">
<![CDATA[
throw new org.mule.module.apikit.exception.NotFoundException("Product ID does not exist!");
]]>
</scripting:script>
</scripting:component>
<apikit:mapping-exception-strategy name="acme-apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<set-property propertyName="Content-Type" value="application/json" />
<set-payload value="{ &quot;message&quot;: &quot;Resource not found&quot; }" />
</apikit:mapping>
<apikit:mapping statusCode="405">
<apikit:exception value="org.mule.module.apikit.exception.MethodNotAllowedException" />
<set-property propertyName="Content-Type" value="application/json" />
<set-payload value="{ &quot;message&quot;: &quot;Method not allowed&quot; }" />
<choice>
<when expression="#[payload.size != 0]">
<!-- Add processing logic here -->
</when>
<otherwise>
<set-property propertyName="http.status" value="404"/>
<set-payload value="Quoth the server, 404"/>
</otherwise>
</choice>
<flow name="get:/products/{id}:acme-config" doc:name="get:/products/{id}:acme-config">
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="GetProductByID" queryTimeout="-1" doc:name="Database">
<jdbc-ee:query key="GetProductByID" value="SELECT * FROM Products WHERE ID=#[flowVars['id']]"/>
</jdbc-ee:outbound-endpoint>
<!-- add transformation logic here -->
</flow>
<flow name="get:/products/{id}:acme-config" doc:name="get:/products/{id}:acme-config">
<set-payload value="#[NullPayload.getInstance()]" doc:name="Set Payload"/>
</flow>
#%RAML 0.8
---
title: Acme REST API
version: v0.1
baseUri: http://localhost:8081/acme/{version}
/products/{id}:
displayName: Product
get:
description: Get Product by ID