Guaranteed delivery means that once a message is placed into a message channel, the messaging system guarantees that the message will reach its destination, even if parts of the application should fail. In general, messaging systems implement the guaranteed delivery pattern, shown in Figure 5.4, by writing messages to persistent storage before attempting to deliver them to their destination.
The following Fuse Mediation Router components support the guaranteed delivery pattern:
File Component in EIP Component Reference
In JMS, the deliveryPersistent
query option indicates whether or not
persistent storage of messages is enabled. Usually it is unnecessary to set this option,
because the default behavior is to enable persistent delivery. To configure all the details
of guaranteed delivery, it is necessary to set configuration options on the JMS provider.
These details vary, depending on what JMS provider you are using. For example, MQSeries,
TibCo, BEA, Sonic, and others, all provide various qualities of service to support
guaranteed delivery.
See JMS in EIP Component Reference for more details.
In ActiveMQ, message persistence is enabled by default. From version 5 onwards, ActiveMQ uses the AMQ message store as the default persistence mechanism. There are several different approaches you can use to enabe message persistence in ActiveMQ.
The simplest option (different from Figure 5.4) is to enable
persistence in a central broker and then connect to that broker using a reliable protocol.
After a message is been sent to the central broker, delivery to consumers is guaranteed. For
example, in the Fuse Mediation Router configuration file, META-INF/spring/camel-context.xml
,
you can configure the ActiveMQ component to connect to the central broker using the
OpenWire/TCP protocol as follows:
<beans ... > ... <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="brokerURL" value="tcp://somehost:61616"/> </bean> ... </beans>
If you prefer to implement an architecture where messages are stored locally before
being sent to a remote endpoint (similar to Figure 5.4), you do this by
instantiating an embedded broker in your Fuse Mediation Router application. A simple way to achieve this
is to use the ActiveMQ Peer-to-Peer protocol, which implicitly creates an embedded broker to
communicate with other peer endpoints. For example, in the camel-context.xml
configuration file, you can configure the ActiveMQ component to connect to all of the peers
in group, GroupA
, as follows:
<beans ... > ... <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="brokerURL" value="peer://GroupA/broker1"/> </bean> ... </beans>
Where broker1
is the broker name of the embedded broker (other peers in the
group should use different broker names). One limiting feature of the Peer-to-Peer protocol
is that it relies on IP multicast to locate the other peers in its group. This makes it
unsuitable for use in wide area networks (and in some local area networks that do not have
IP multicast enabled).
A more flexible way to create an embedded broker in the ActiveMQ component is to exploit ActiveMQ's VM protocol, which connects to an embedded broker instance. If a broker of the required name does not already exist, the VM protocol automatically creates one. You can use this mechanism to create an embedded broker with custom configuration. For example:
<beans ... > ... <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="brokerURL" value="vm://broker1?brokerConfig=xbean:activemq.xml"/> </bean> ... </beans>
Where activemq.xml
is an ActiveMQ file which configures the embedded broker
instance. Within the ActiveMQ configuration file, you can choose to enable one of the
following persistence mechanisms:
AMQ persistence(the default) — A fast and reliable message store that is native to ActiveMQ. For details, see amqPersistenceAdapter and AMQ Message Store.
JDBC persistence — Uses JDBC to store messages in any JDBC-compatible database. For details, see jdbcPersistenceAdapter and ActiveMQ Persistence.
Journal persistence — A fast persistence mechanism that stores messages in a rolling log file. For details, see journalPersistenceAdapter and ActiveMQ Persistence.
Kaha persistence — A persistence mechanism developed specifically for ActiveMQ. For details, see kahaPersistenceAdapter and ActiveMQ Persistence.
See ActiveMQ in EIP Component Reference for more details.
The ActiveMQ Journal component is optimized for a special use case where multiple, concurrent producers write messages to queues, but there is only one active consumer. Messages are stored in rolling log files and concurrent writes are aggregated to boost efficiency.
See ActiveMQ Journal in EIP Component Reference for more details.