From ce43eb4e2bf53606113b2bdc9f97d942a539f4fb Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Thu, 10 May 2012 23:43:20 -0400 Subject: [PATCH] AMQP-193 - Add RabbitTransactionManager to RefDoc For reference see: https://jira.springsource.org/browse/AMQP-193 --- src/docbkx/amqp.xml | 57 +++++++++++++++++++++++++++++++++------ src/docbkx/quick-tour.xml | 11 +++++--- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/src/docbkx/amqp.xml b/src/docbkx/amqp.xml index 2b63b69a..e2544f9b 100644 --- a/src/docbkx/amqp.xml +++ b/src/docbkx/amqp.xml @@ -140,7 +140,7 @@ /** * The queue is durable, non-exclusive and non auto-delete. - * + * * @param name the name of the queue. */ public Queue(String name) { @@ -699,7 +699,7 @@ Object receiveAndConvert(String queueName) throws AmqpException;]]>AmqpTemplate for more detail. By default, a new temporary queue is used for each reply. However, a single reply queue can be configured on the template, - which allows you to set arguments on that queue (such as 'ha_args="all"' for mirrored queues). In this case, however, + which allows you to set arguments on that queue (such as 'ha_args="all"' for mirrored queues). In this case, however, you must also provide a <reply-listener/> sub element. This element provides a listener container for the reply queue, with the template being the listener. All of the attributes allowed on a <listener-container/> are allowed on the element, except for connection-factory and @@ -1052,6 +1052,47 @@ public class ExampleExternalTransactionAmqpConfiguration { also means that if it is under load there is a natural back off before the message can be consumed again. +
+ Using the RabbitTransactionManager + + The + RabbitTransactionManager + is an alternative to executing Rabbit operations within, and synchronized + with, external transactions. This Transaction Manager is an implementation + of the + PlatformTransactionManager + interface and should be used with a single Rabbit ConnectionFactory. + + + This strategy is not able to provide XA transactions, for example in + order to share transactions between messaging and database access. + + + Application code is required to retrieve the transactional Rabbit resources + via ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactory, boolean) + instead of a standard Connection.createChannel() call with + subsequent Channel creation. When using Spring's + RabbitTemplate, + it will autodetect a thread-bound Channel and automatically participate + in it. + + + With Java Configuration you can setup a new RabbitTransactionManager + using: + + + + If you prefer using XML configuration, declare the following bean in your + XML Application Context file: + + + +]]> +
@@ -1190,7 +1231,7 @@ public class ExampleExternalTransactionAmqpConfiguration { taskExecutor - + A reference to a Spring TaskExecutor (or standard JDK 1.5+ Executor) for executing listener invokers. Default is a SimpleAsyncTaskExecutor, using internally managed threads. @@ -1198,7 +1239,7 @@ public class ExampleExternalTransactionAmqpConfiguration { errorHandler - + A reference to an ErrorHandler strategy for handling any uncaught Exceptions that may occur during the execution of the MessageListener. @@ -1206,14 +1247,14 @@ public class ExampleExternalTransactionAmqpConfiguration { concurrency - + The number of concurrent consumers to start for each listener. connectionFactory - + A reference to the connectionFactory; when configuring using the XML namespace, the default referenced bean name is "rabbitConnectionFactory". @@ -1221,7 +1262,7 @@ public class ExampleExternalTransactionAmqpConfiguration { messageConverter - + A reference to the MessageConverter strategy for converting AMQP Messages to listener method arguments for any referenced 'listener' that is a POJO. Default is @@ -1243,7 +1284,7 @@ public class ExampleExternalTransactionAmqpConfiguration { the features and recovery scenarios individually. The primary reconnection features are enabled by the - CachingConnectionFactory itself. + CachingConnectionFactory itself. It is also often beneficial to use the RabbitAdmin auto-declaration features. In addition, if you care about guaranteed delivery, you probably also need to use the diff --git a/src/docbkx/quick-tour.xml b/src/docbkx/quick-tour.xml index d9e1cb75..fd4593b5 100644 --- a/src/docbkx/quick-tour.xml +++ b/src/docbkx/quick-tour.xml @@ -58,10 +58,13 @@ template.convertAndSend("myqueue", "foo"); String foo = (String) template.receiveAndConvert("myqueue");]]> - +