View on GitHub

ironmq-si

Iron IO Spring Integration Extensions

Download this project as a .zip file Download this project as a tar.gz file

Iron MQ Spring Integration Extensions

This project provides Spring Integration extensions for inbound and outbound channel adapters.

Configuring a Client Factory

Both the inbound and outbound adapters require a client factory which is responsible for creating an instance of an io.iron.ironmq.Client. This project provides a default implementation of the factory and a namespace handler.

The example below shows the creation of a default client factory using SpEL to get the IronMQ projectId and token values.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int-ironmq="http://trevershick.github.com/schema/integration/ironmq"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
	http://trevershick.github.com/schema/integration/ironmq http://trevershick.github.com/schema/integration/ironmq/spring-integration-ironmq.xsd">

    <int-ironmq:default-client-factory id="clientFactory" ironmq-project="#{projectId}" ironmq-token="#{token}"/>

</beans>

Configuring the Inbound Channel Adapter

Shown below is an example of an inbound channel adapter configuration. I will skip the requisite beans root element and default-client-factory element as it is shown above in the docs. The inbound queue can be defined either as a regular literal/SpEL at initialization or a SpEL expression evaluated each time receive() is called on the underlying MessageSource.

<int-ironmq:inbound-channel-adapter 
    auto-startup="true" 
    channel="ironmqInboundChannel" 
    queue-name="queue1" client-factory="clientFactory">
    <int:poller fixed-rate="5000" />
</int-ironmq:inbound-channel-adapter>

<!-- poller polling the queue name determined by the queue-name-expression -->
<int-ironmq:inbound-channel-adapter 
    auto-startup="true" 
    channel="ironmqInboundChannel" 
    queue-name-expression="new String('whateverQueue')" client-factory="clientFactory">
    <int:poller fixed-rate="5000" />
</int-ironmq:inbound-channel-adapter>

Configuring the Outbound Channel Adapter

Shown below is an example of an outbound channel adapter configuration. As above, I will skip the requisite beans root element. The queue-name value is a literal value below, but you can use expressions as well that will be evaluated each time receive() is called on the underlying MessageSource.

<!-- uses the specified queue 'queue1' -->
<int-ironmq:outbound-channel-adapter id="out1" queue-name="queue1" client-factory="clientFactory" channel="c1" />

<!-- pushes the message to the queue name based on the expression (in this case queue2) -->
<int-ironmq:outbound-channel-adapter id="out2" queue-name-expression="new String('queue2').toLowerCase()" client-factory="clientFactory" channel="c2" />

<!-- by default, the expression used is 'headers.ironmq_queue', so this -->
<!-- will send to whatever queue is identified in the message headers   -->
<int-ironmq:outbound-channel-adapter id="out3" client-factory="clientFactory" channel="c3" />

Caveats

The Iron MQ Java libraries used in this project were authored by @iron-io but they're not yet available on a central maven repository. You will need to install them into your local repository. You can install the file (currently checked in to this project under repo/... yeah, i know) via the following command:

mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file -Dfile=ironmq-0.0.9.jar -DgroupId=io.iron -DartifactId=ironmq -Dversion=0.0.9 -Dpackaging=jar

Support or Contact

Submit any issues on the GitHub issues page. I'll do my best to address any issues quickly.

comments powered by Disqus