Skip to content

Instantly share code, notes, and snippets.

@Module(name = "validator", schemaVersion = "1.0-SNAPSHOT")
public class ValidatorModule {
/**
* Processor to filter our invalid products from a List payload.
* <p/>
* {@sample.xml ../../../doc/Validator-connector.xml.sample validator:my-processor}
*
* @param products The products to validate
@johndemic
johndemic / gist:1401999
Created November 28, 2011 20:53
How are custom processor will look in a Mule config file with its custom namespace.
<validator:product/>
@johndemic
johndemic / mule-config.xml
Created November 28, 2011 20:57
A Mule configuration using the custom validator
<flow name="Product Submission">
<http:inbound-endpoint address="http://localhost:8080/products"/>
<byte-array-to-string-transformer/>
<json:json-to-object-transformer returnClass="java.util.ArrayList"/>
<validator:product/>
<vm:outbound-endpoint path="products.out"/>
</flow>
@johndemic
johndemic / gist:1410821
Created November 30, 2011 21:07
Maven command line to generate a Mule Module for our Circuit Breaker
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.devkit -DarchetypeArtifactId=mule-devkit-archetype-generic -DarchetypeVersion=3.0.1 -DarchetypeRepository=http://repository.mulesoft.org/releases/ -DgroupId=com.acmesoft -DartifactId=circuit-breaker-module -Dversion=1.0-SNAPSHOT -DmuleVersion=3.2.0 -DmuleModuleName=CircuitBreaker -DmuleModulePackage=com.acmesoft.integration
@johndemic
johndemic / mule-circuit-breaker-config.xml
Created November 30, 2011 21:14
Mule Circuit Breaker Configuration
<circuitbreaker:config breakerName="testingBreaker" tripThreshold="5" tripTimeout="300000"/>
<flow name="testFlow">
<vm:inbound-endpoint path="vm.in"/>
<circuitbreaker:filter/>
<test:component throwException="true"/>
<vm:outbound-endpoint path="vm.out"/>
<default-exception-strategy>
<circuitbreaker:trip tripOnException="org.mule.tck.exceptions.FunctionalTestException"/>
</default-exception-strategy>
/**
* Mule Development Kit
* Copyright 2010-2011 (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
/**
* Custom processor
* <p/>
* {@sample.xml ../../../doc/CircuitBreaker-connector.xml.sample circuitbreaker:trip}
*
* @param exceptionMessage The exception.
* @param tripOnException The exception type we should trip on.
* @return Some string
*/
@Processor
/**
* Custom processor
* <p/>
* {@sample.xml ../../../doc/CircuitBreaker-connector.xml.sample circuitbreaker:filter}
*
* @param payload The message payload
* @return Some string
*/
@Processor
public Object filter(@Payload Object payload) {
Integer getFailureCount() {
try {
objectStoreMutex.acquire();
} catch (InterruptedException e) {
logger.error("Could not acquire mutex", e);
}
ObjectStore objectStore = objectStoreManager.getObjectStore(MuleProperties.OBJECT_STORE_DEFAULT_PERSISTENT_NAME);
String key = String.format("%s.failureCount", breakerName);
<flow name="testFlow">
<vm:inbound-endpoint path="in"/>
<esper:send eventPayload-ref="#[payload:]"/>
<vm:outbound-endpoint path="out"/>
</flow>
<flow name="Event Listener Flow">
<esper:listen statement="select count(*) from TestEvent
.win:time_batch(5, 'FORCE_UPDATE, START_EAGER') having count(*) &gt; 0"/>
<esper:get-event-property key="count(*)"/>