add CachingConnectionFactory to docs.
add wcf quickstart
This commit is contained in:
@@ -252,6 +252,64 @@
|
||||
otherwise be part of a ConnectionFactory 'Wrappers' (to be discussed
|
||||
later) are provided.</para>
|
||||
</note></para>
|
||||
|
||||
<section>
|
||||
<title>Caching EMS Resources</title>
|
||||
|
||||
<para>The class
|
||||
Spring.Messaging.Nms.Connections.CachingConnectionFactory </para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Caching Messaging Resources</title>
|
||||
|
||||
<para>The standard API usage of NMS and other JMS inspired APIs involves
|
||||
creating many intermediate objects. To send a message the following
|
||||
'API' walk is performed</para>
|
||||
|
||||
<programlisting>IConnectionFactory->IConnection->ISession->IMessageProducer->Send</programlisting>
|
||||
|
||||
<para>Between the ConnectionFactory and the Send operation there are
|
||||
three intermediate objects that are created and destroyed. To optimise
|
||||
the resource usage and increase performance two implementations of
|
||||
IConnectionFactory are provided. Note that the TIBCO EMS implementation
|
||||
is not based on interfaces and an alternative strategy was selected for
|
||||
the time being. See the last section in this manual for details.</para>
|
||||
|
||||
<section>
|
||||
<title>SingleConnectionFactory</title>
|
||||
|
||||
<para><classname>Spring.Messaging.Nms.Connections.SingleConnectionFactory
|
||||
</classname>will return the same connection on all calls to
|
||||
CreateConnection and ignore calls to Close.</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>CachingConnectionFactory</title>
|
||||
|
||||
<para><classname>Spring.Messaging.Nms.Connections.CachingConnectionFactory</classname>
|
||||
extends the functionality of SingleConnectionFactory and adds the
|
||||
caching of Sessions, MessageProducers, and MessageConsumers. </para>
|
||||
|
||||
<para> The initial cache size is set to 1, use the property
|
||||
<literal>SessionCacheSize</literal> to increase the number of cached
|
||||
sessions. Note that the number of actual cached sessions will be more
|
||||
than that number as sessions are cached based on their acknowledgment
|
||||
mode, so there can be up to 4 cached session instances when
|
||||
SessionCacheSize is set to one, one for each
|
||||
<classname>AcknowledgementMode</classname>.
|
||||
<classname>MessageProducers</classname> and
|
||||
<classname>MessageConsumers</classname> are cached within their owning
|
||||
session and also take into account the unique properties of the
|
||||
producers and consumers when caching. </para>
|
||||
|
||||
<para><classname>MessageProducers</classname> are cached based on
|
||||
their destination. <classname>MessageConsumers</classname> are cached
|
||||
based on a key composed of the destination, selector, noLocal delivery
|
||||
flag, and the durable subscription name (if creating durable
|
||||
consumers).</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -1159,9 +1217,10 @@ namespace MyApp
|
||||
<row>
|
||||
<entry>pubsub-domain</entry>
|
||||
|
||||
<entry><para>An optional boolean value. Set to true for the publish-subscribe domain
|
||||
(Topics) or false (the default) for point-to-point domain (Queues). This is useful
|
||||
when using the default implementation for destination resolvers.
|
||||
<entry><para>An optional boolean value. Set to true for the
|
||||
publish-subscribe domain (Topics) or false (the default) for
|
||||
point-to-point domain (Queues). This is useful when using the
|
||||
default implementation for destination resolvers.
|
||||
</para></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
|
||||
165
doc/reference/src/wcf-quickstart.xml
Normal file
165
doc/reference/src/wcf-quickstart.xml
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<chapter id="wcf-quickstart">
|
||||
<title>WCF QuickStart</title>
|
||||
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>The WCF quickstart application shows how to configure your WCF
|
||||
services using dependency injection and how to to apply AOP advice to your
|
||||
services. It is based on the same interfaces used in the <link
|
||||
linkend="remoting-quickstart">portable service abstractions
|
||||
quickstart</link> example that demonstrates similar features for .NET
|
||||
Remoting, Enterprise Services, and ASMX web sevices. At the moment the
|
||||
quickstart example is only available as a VS.NET 2008 solution.</para>
|
||||
|
||||
<para>There are two server applications in the solution, one is a web
|
||||
application where the WCF service will be hosted, and the other is a
|
||||
self-hosting console application, (Spring.WcfQuickStart.Server.2008. The
|
||||
client application is located in Sprng.WcfQuickStart.ClientApp.2008. To
|
||||
run the solution make sure that all three projects are set to
|
||||
startup.</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>The server side</title>
|
||||
|
||||
<para>The service contract is shown below</para>
|
||||
|
||||
<programlisting> [ServiceContract(Namespace = "http://Spring.WcfQuickStart")]
|
||||
public interface ICalculator
|
||||
{
|
||||
[OperationContract]
|
||||
double Add(double n1, double n2);
|
||||
[OperationContract]
|
||||
double Subtract(double n1, double n2);
|
||||
[OperationContract]
|
||||
double Multiply(double n1, double n2);
|
||||
[OperationContract]
|
||||
double Divide(double n1, double n2);
|
||||
[OperationContract]
|
||||
string GetName();
|
||||
}</programlisting>
|
||||
|
||||
<para>and the implementation is straightforward, only adding a property
|
||||
that controls how long each method should sleep. An abbreviated listing of
|
||||
the implementation is shown below </para>
|
||||
|
||||
<programlisting> public class CalculatorService : ICalculator
|
||||
{
|
||||
private int sleepInSeconds;
|
||||
|
||||
public int SleepInSeconds
|
||||
{
|
||||
get { return sleepInSeconds; }
|
||||
set { sleepInSeconds = value; }
|
||||
}
|
||||
|
||||
public double Add(double n1, double n2)
|
||||
{
|
||||
Thread.Sleep(sleepInSeconds*1000);
|
||||
return n1 + n2;
|
||||
}
|
||||
|
||||
|
||||
// other methods omitted for brevity.
|
||||
|
||||
}</programlisting>
|
||||
|
||||
<section>
|
||||
<title>DI using dynamic proxies</title>
|
||||
|
||||
<para>The approach using dynamic proxies is used in the console
|
||||
application inside the Spring.WcfQuickStart.Server.2008 project. For
|
||||
more information on this approach refer to this <link
|
||||
linkend="wcf-di-proxy">section</link> in the reference docs. The
|
||||
configuration of your service is done as you would typically do with
|
||||
Spring, including applying of any AOP advice. The class is hosted inside
|
||||
the console application through the use of Spring's
|
||||
<classname>ServiceHostFactoryObject</classname> exporter. The
|
||||
configuration for the server console application is shown below. </para>
|
||||
|
||||
<programlisting> <objects xmlns="http://www.springframework.net"
|
||||
xmlns:aop="http://www.springframework.net/aop">
|
||||
|
||||
<!-- Service definition -->
|
||||
<object id="calculator" singleton="false"
|
||||
type="Spring.WcfQuickStart.CalculatorService, Spring.WcfQuickStart.ServerApp">
|
||||
<property name="SleepInSeconds" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="serviceOperation" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop">
|
||||
<property name="pattern" value="Spring.WcfQuickStart.*"/>
|
||||
</object>
|
||||
|
||||
<object id="perfAdvice" type="Spring.WcfQuickStart.SimplePerformanceInterceptor, Spring.WcfQuickStart.ServerApp">
|
||||
<property name="Prefix" value="Service Layer Performance"/>
|
||||
</object>
|
||||
|
||||
<aop:config>
|
||||
<aop:advisor pointcut-ref="serviceOperation" advice-ref="perfAdvice"/>
|
||||
</aop:config>
|
||||
|
||||
<!-- host the service object -->
|
||||
<object id="calculatorServiceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryObject, Spring.Services">
|
||||
<property name="TargetName" value="calculator" />
|
||||
</object>
|
||||
|
||||
</objects></programlisting>
|
||||
|
||||
<para>Look at the standard WCF configuration section in App.config for
|
||||
additional configuration details. In that section you will see that the
|
||||
name of the WCF service corresponds to the name of the service object
|
||||
inside the spring container.</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>DI using WCF extension points</title>
|
||||
|
||||
<para>This approach uses Spring specific implementation of the WCF
|
||||
interfaces
|
||||
<classname>System.ServiceModel.Dispatcher.IInstanceProvider</classname>
|
||||
and
|
||||
<classname>System.ServiceModel.Description.IServiceBehavior</classname>
|
||||
are used to integrate Spring directly into the instancing of WCF
|
||||
services. For more information on this approach refer to this <link
|
||||
linkend="wcf-di-extension-points">section</link> of the reference
|
||||
documentation. The web application shows this approach in action.</para>
|
||||
|
||||
<para>Much of the configuration ob the objects is the same as before,
|
||||
the .svc file though refers to the type of the service inside the Spring
|
||||
container as well as using Spring's
|
||||
Spring.ServiceModel.Activation.ServiceHostFactory. The .svc file is
|
||||
shown below.</para>
|
||||
|
||||
<programlisting><%@ ServiceHost Language="C#" Debug="true" Service="Spring.WcfQuickStart.CalculatorService"
|
||||
Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>
|
||||
</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Client access </title>
|
||||
|
||||
<para>The project Spring.WcfQuickStart.ClientApp.2008 is a console
|
||||
application that calls the two WCF services. It creates a client side
|
||||
proxy based on using ChannelFactory<T>.CreateChannel. Running the
|
||||
client application produces the following output.</para>
|
||||
|
||||
<programlisting>--- Press <return> to continue ---
|
||||
Web Calculator
|
||||
Add(1, 1) : 2
|
||||
Divide(11, 2) : 5.5
|
||||
Multiply(2, 5) : 10
|
||||
Subtract(7, 4) : 3
|
||||
|
||||
ServerApp Calculator
|
||||
Add(1, 1) : 2
|
||||
Divide(11, 2) : 5.5
|
||||
Multiply(2, 5) : 10
|
||||
Subtract(7, 4) : 3
|
||||
|
||||
--- Press <return> to continue ---
|
||||
</programlisting>
|
||||
</section>
|
||||
</chapter>
|
||||
Reference in New Issue
Block a user