Skip to content

Instantly share code, notes, and snippets.

@johndemic
johndemic / gist:1998005
Created March 8, 2012 01:59
Execute the PHP dispatch script
php dispatch.php logging-exchange logs.info "Application started"
@johndemic
johndemic / gist:1996848
Created March 7, 2012 22:49
A script to publish messages to an AMQP exchange
<?php
// Establish a connection to the locally running RabbitMQ instance
$cnn = new AMQPConnection();
$cnn->connect();
// Create a channel
$ch = new AMQPChannel($cnn);
// Declare the exchange specified by the first argument to the script
@johndemic
johndemic / gist:1996793
Created March 7, 2012 22:37
Output Log Messages Published to the logging-exchange
<amqp:connector name="amqpConnector" />
<flow name="logging.wildcard">
<amqp:inbound-endpoint
exchangeName="logging-exchange"
exchangeType="topic"
exchangeAutoDelete="false"
exchangeDurable="true"
queueName="console-logger"
queueDurable="true"
@johndemic
johndemic / AggregationTestCase.java
Created March 7, 2012 15:19
Complete Async Aggregation Example
package org.mule.example.cep;
import org.mule.api.MuleMessage;
import org.mule.api.MuleMessageCollection;
import org.mule.api.client.MuleClient;
import org.mule.tck.FunctionalTestCase;
import org.mule.util.CollectionUtils;
import java.util.*;
@johndemic
johndemic / gist:1933907
Created February 28, 2012 17:43
Configuring a flow to use up to 500 threads to asynchronous process messages arriving a VM inbound-endpoint.
<queued-asynchronous-processing-strategy name="allow500Threads" maxThreads="500"/>
<flow name="acceptOrders" processingStrategy="allow500Threads">
<vm:inbound-endpoint path="acceptOrders" exchange-pattern="one-way"/>
<vm:outbound-endpoint path="commonProcessing" exchange-pattern="one-way"/>
</flow>
@johndemic
johndemic / gist:1933874
Created February 28, 2012 17:35
Chunking a Group of Split Messages
<flow name="aggregate.chunks">
<vm:inbound-endpoint path="foo.bar"/>
<message-chunk-aggregator/>
<vm:outbound-endpint path="chunk.out"/>
</flow>
@johndemic
johndemic / gist:1933852
Created February 28, 2012 17:31
Split a java.util.List and send each object as a message to order.queue
<collection-splitter/>
<jms:outbound-endpoint queue="order.queue"/>
@johndemic
johndemic / gist:1933801
Created February 28, 2012 17:21
Asynchronously Processing a Message Group
<flow name="aggregate.messages">
<vm:inbound-endpoint path="foo.bar" exchange-pattern=”one-way”/>
<collection-aggregator timeout="6000" failOnTimeout="false"/>
<vm:outbound-endpoint path="messages.out"/>
</flow>
@johndemic
johndemic / gist:1933788
Created February 28, 2012 17:19
Asynchronously Bridging and HTTP Request to JMS
<flow name="HTTP to JMS Flow">
<http:inbound-endpoint address="http://localhost:8080/foo" exchange-pattern="one-way"/>
<jms:outbound-endpoint queue="messages"/>
</flow>
public class DelayingOutboundRouter extends AbstractOutboundRouter {
static ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5);
@Override
protected MuleEvent route(MuleEvent event) throws MessagingException {
Future<MuleEvent> scheduled = executorService.schedule(
new MessageProcessorRunner(event.getMessage(), routes.get(0), event), 5, TimeUnit.SECONDS);
MuleEvent result;