Show use of CachingConnectionFactory in docs for ActiveMQ integration

Show use of ConnectionUtils.GetConnectionTxPair when using 'low level' integration with Spring's declarative tx mgmt.
This commit is contained in:
markpollack
2009-03-20 13:18:11 +00:00
parent f7b5da302e
commit a86b745710
2 changed files with 30 additions and 3 deletions

View File

@@ -875,14 +875,19 @@ namespace MyApp
implementation, <literal>SimpleMessageListenerContainer</literal>.
<literal>SimpleMessageListenerContainer</literal> creates a fixed number
of JMS Sessions/MessageConsumer pairs as set by the property
<property>ConcurrentConsumers</property>. Here is a sample
configuration</para>
<property>ConcurrentConsumers</property>. The default value of
ConcurrentConsumers is one. Here is a sample configuration</para>
<programlisting language="myxml">
&lt;object id="ConnectionFactory" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ"&gt;
&lt;object id="ActiveMqConnectionFactory" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ"&gt;
&lt;constructor-arg index="0" value="tcp://localhost:61616"/&gt;
&lt;/object&gt;
&lt;object id="ConnectionFactory" type="Spring.Messaging.Nms.Connections.CachingConnectionFactory, Spring.Messaging.Nms"&gt;
&lt;constructor-arg index=0" ref="ActiveMqConnectionFactory"/&gt;
&lt;property name="SessionCacheSize" value="10"/&gt;
&lt;/object&gt;
&lt;object id="MyMessageListener" type="MyApp.SimpleMessageListener, MyApp"/&gt;
&lt;object id="MessageListenerContainer" type="Spring.Messaging.Nms.Listener.SimpleMessageListenerContainer, Spring.Messaging.Nms"&gt;

View File

@@ -405,6 +405,28 @@
<literal>ConnectionUtils</literal> contains the static method
<literal>ConnectionTxPair GetConnectionTxPair(IDbProvider provider)
</literal>which serves this purpose.</para>
<programlisting>public class LowLevelIntegration
{
// Spring's IDbProvider abstraction
private IDbProvider dbProvider;
public IDbProvider dbProvider
{
set { dbProvider = value; }
}
public void DoWork() {
ConnectionTxPair connTxPair = ConnectionUtils.GetConnectionTxPair(dbProvider);
//Use some data access library that allows you to pass in the transaction
DbWrapper dbWrapper = new DbWrapper();
string cmdText = ... // some command text
dbWrapper.ExecuteNonQuery(cmdText, connTxPair.Transaction);
}
}
</programlisting>
</sect2>
</sect1>