Skip to content

Instantly share code, notes, and snippets.

View fganora's full-sized avatar

Francesco Ganora fganora

View GitHub Profile
<base64-encoder-transformer doc:name="Base64 encode" encoding="utf8"/>
@fganora
fganora / gist:0d0020724fe3f0ed3933bcd61f037b29
Last active April 25, 2017 07:33
Register and Get Mule Registry object
muleContext.getRegistry().registerObject("<key>", <object>)
muleContext.getRegistry().get("<key>")
@fganora
fganora / gist:b78871e42c2e48d0a1b111c46b31e013
Created October 19, 2016 07:13
Examples: Customize CSV output in Mule DataWeave
%dw 1.0
%output application/csv separator=";"
---
-----------------------------
%dw 1.0
%input in0 application/json
%output application/csv encoding="US-ASCII"
---
@fganora
fganora / gist:707d734f39db33312e5c091a62922656
Created October 19, 2016 07:18
Mule Custom Java Transformer template
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class UppercaseTransformer extends AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
// custom code here
return <result>;
@fganora
fganora / gist:3e95550121d1bd0f4730b448b13173e8
Created October 19, 2016 07:19
Mule configuration for ActiveMQ connector with RedeliveryPolicy
<spring:beans>
<!-- ActiveMQ -->
<spring:bean class="org.apache.activemq.RedeliveryPolicy" id="redeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5"/>
<spring:property name="initialRedeliveryDelay" value="5000"/>
<spring:property name="redeliveryDelay" value="2000"/>
<spring:property name="useExponentialBackOff" value="false"/>
<spring:property name="backOffMultiplier" value="2"/>
</spring:bean>
<spring:bean class="org.apache.activemq.ActiveMQConnectionFactory" id="amqFactory" lazy-init="true">
@fganora
fganora / gist:96f3430a9a8c686cce49a48d2fad3051
Created October 19, 2016 07:21
Mule: calling DataWeave expression from MEL
#[dw("my object:{id:payload.accountid, user:payload.user}")]
@fganora
fganora / gist:89496a1e852b27f12aed678e6158f4c5
Created October 19, 2016 07:23
Sample Log4j2.xml for Mule application
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Appenders>
<RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}apdev-flights-ws.log"
filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}apdev-flights-ws-%i.log">
<PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
<SizeBasedTriggeringPolicy size="10 MB" />
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
@fganora
fganora / gist:c36e324946e13503c3dbbeb865541a79
Created October 19, 2016 07:28
Mule: configuration to access shared flows from "utility" Mule app (app packaged in JAR and JAR on client app's classpath)
<spring:beans>
<spring:import resource="class path:utilityapp.xml"/>
</spring:beans>
@fganora
fganora / gist:7382be71bf2f258a176a10f79fd6b4d3
Created October 19, 2016 07:45
Programmatic stop/start of Mule flows (Groovy)
// stopping
def myFlow = muleContext.registry.lookupFlowConstruct('<flow name>');
if (myFlow.isStarted()) myFlow.stop()
// starting
def myFlow = muleContext.registry.lookupFlowConstruct('<flow name>');
if (!myFlow.isStarted()) myFlow.start()
@fganora
fganora / gist:7f7d15466400b4ab9096df0b343a50f7
Created October 19, 2016 07:48
Mule configuration to enforce prefixing flow and session variables with flowVars./sessionVars. for access in MEL
<configuration>
<expression-language autoResolveVariables="false"/>
</configuration>