Update reference documentation generation tools to get source highlighting [SPRNET-1045]
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<chapter id="nms-quickstart">
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<chapter xml:id="nms-quickstart" xmlns="http://docbook.org/ns/docbook" version="5">
|
||||
<title>NMS QuickStart</title>
|
||||
|
||||
<section>
|
||||
@@ -58,51 +75,51 @@
|
||||
<para>Queues are shown in red and topics in green.</para>
|
||||
</section>
|
||||
|
||||
<section id="nms-gateways">
|
||||
<section xml:id="nms-gateways">
|
||||
<title>Gateways</title>
|
||||
|
||||
<para>Gateways represent the service operation to send a message. The
|
||||
client will send a stock request to the server based on the contract
|
||||
defined by the <classname>IStockService</classname> interface .</para>
|
||||
defined by the <literal>IStockService</literal> interface .</para>
|
||||
|
||||
<programlisting> public interface IStockService
|
||||
<programlisting language="csharp"> public interface IStockService
|
||||
{
|
||||
void Send(TradeRequest tradeRequest);
|
||||
}</programlisting>
|
||||
|
||||
<para>The server will send market data to the clients based on the
|
||||
contract defined by the <classname>IMarketDataService</classname>
|
||||
contract defined by the <literal>IMarketDataService</literal>
|
||||
interface.</para>
|
||||
|
||||
<programlisting> public interface IMarketDataService
|
||||
<programlisting language="csharp"> public interface IMarketDataService
|
||||
{
|
||||
void SendMarketData();
|
||||
}</programlisting>
|
||||
|
||||
<para>The market data gateway has no method parameters as it is assumed
|
||||
that implementations will manage the data to send internally. The
|
||||
<classname>TradeRequest</classname> object is one of the data objects that
|
||||
<literal>TradeRequest</literal> object is one of the data objects that
|
||||
will be exchanged in the application and is discussed in the next
|
||||
section.</para>
|
||||
|
||||
<para>The use of interfaces allows for multiple implementations to be
|
||||
created. Implementations that use messaging to communicate will be based
|
||||
on the Spring's <classname>NmsGateway</classname> class and will be
|
||||
on the Spring's <literal>NmsGateway</literal> class and will be
|
||||
discussed later. stub or mock implementations can be used for testing
|
||||
purposes.</para>
|
||||
</section>
|
||||
|
||||
<section id="nms-messagedata">
|
||||
<section xml:id="nms-messagedata">
|
||||
<title>Message Data</title>
|
||||
|
||||
<para>The <classname>TradeRequest</classname> object shown above contains
|
||||
<para>The <literal>TradeRequest</literal> object shown above contains
|
||||
all the information required to process a stock order. To promote the
|
||||
interoperability of this data across different platforms the
|
||||
<classname>TradeRequest</classname> class is generated from an XML Schema
|
||||
<literal>TradeRequest</literal> class is generated from an XML Schema
|
||||
using Microsoft's Schema Definition Tool (xsd.exe). The schema for trade
|
||||
request is shown below</para>
|
||||
|
||||
<programlisting><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||
<programlisting language="myxml"><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||
targetNamespace="http://www.springframework.net/nms/common/2008-08-05">
|
||||
|
||||
<xs:element name="TradeRequest">
|
||||
@@ -127,7 +144,7 @@
|
||||
properties for each of the element names. A partial code listing of the
|
||||
TradeRequest class is shown below</para>
|
||||
|
||||
<programlisting>// This code was generated by a tool.
|
||||
<programlisting language="csharp">// This code was generated by a tool.
|
||||
public partial class TradeRequest {
|
||||
|
||||
public string Ticker {
|
||||
@@ -152,16 +169,16 @@
|
||||
|
||||
}</programlisting>
|
||||
|
||||
<para>The schema and the <classname>TradeRequest</classname> class are
|
||||
located in the project <classname>Spring.NmsQuickStart.Common</classname>.
|
||||
<para>The schema and the <literal>TradeRequest</literal> class are
|
||||
located in the project <literal>Spring.NmsQuickStart.Common</literal>.
|
||||
This common project will be shared between the server and client for
|
||||
convenience.</para>
|
||||
|
||||
<para>When sending a response back to the client the type
|
||||
<classname>TradeResponse</classname> will be used. The schema for the
|
||||
<classname>TradeResponse</classname> is shown below</para>
|
||||
<literal>TradeResponse</literal> will be used. The schema for the
|
||||
<literal>TradeResponse</literal> is shown below</para>
|
||||
|
||||
<programlisting><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||
<programlisting language="myxml"><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||
targetNamespace="http://www.springframework.net/nms/common/2008-08-05">
|
||||
|
||||
<xs:element name="TradeResponse">
|
||||
@@ -179,10 +196,10 @@
|
||||
|
||||
</xs:schema></programlisting>
|
||||
|
||||
<para>The <classname>TradeResponse</classname> type also generated from a
|
||||
<para>The <literal>TradeResponse</literal> type also generated from a
|
||||
schema using xsd.exe. A partial code listing is shown below</para>
|
||||
|
||||
<programlisting>// This code was generated by a tool.
|
||||
<programlisting language="csharp">// This code was generated by a tool.
|
||||
|
||||
public partial class TradeResponse {
|
||||
|
||||
@@ -212,15 +229,15 @@
|
||||
structure.</para>
|
||||
</section>
|
||||
|
||||
<section id="nms-handlers">
|
||||
<section xml:id="nms-handlers">
|
||||
<title>Message Handlers</title>
|
||||
|
||||
<para>When the <classname>TradeRequest</classname> message is received by
|
||||
<para>When the <literal>TradeRequest</literal> message is received by
|
||||
the server, it will be handled by the class
|
||||
<classname>Spring.NmsQuickStart.Server.Handlers.StockAppHandler
|
||||
</classname>shown below</para>
|
||||
<literal>Spring.NmsQuickStart.Server.Handlers.StockAppHandler
|
||||
</literal>shown below</para>
|
||||
|
||||
<programlisting> public class StockAppHandler
|
||||
<programlisting language="csharp"> public class StockAppHandler
|
||||
{
|
||||
private IExecutionVenueService executionVenueService;
|
||||
|
||||
@@ -260,7 +277,7 @@
|
||||
client is the class Spring.NmsQuickStart.Client.Handlers.StockAppHandler
|
||||
and is shown below.</para>
|
||||
|
||||
<programlisting> public class StockAppHandler
|
||||
<programlisting language="csharp"> public class StockAppHandler
|
||||
{
|
||||
|
||||
// definition of stockController omitted for brevity.
|
||||
@@ -292,10 +309,10 @@
|
||||
<title>Message Converters</title>
|
||||
|
||||
<para>The implementation of IMessageConverter used is
|
||||
<classname>Spring.NmsQuickStart.Common.Converters.XmlMessageConverter</classname>.
|
||||
<literal>Spring.NmsQuickStart.Common.Converters.XmlMessageConverter</literal>.
|
||||
This converter adds the ability to marshal and unmarshal objects to and
|
||||
from XML strings. It also uses Spring's
|
||||
<classname>SimpleMessageConverter</classname> to convert Hashtables,
|
||||
<literal>SimpleMessageConverter</literal> to convert Hashtables,
|
||||
strings, and byte arrays. In order to pass information about the
|
||||
serialized type, type information is put in the message properties. The
|
||||
type information can be either the class name or an integer value
|
||||
@@ -305,7 +322,7 @@
|
||||
The XML configuration used to configure these objects is shown
|
||||
below</para>
|
||||
|
||||
<programlisting> <object name="XmlMessageConverter" type="Spring.NmsQuickStart.Common.Converters.XmlMessageConverter, Spring.NmsQuickStart.Common">
|
||||
<programlisting language="myxml"> <object name="XmlMessageConverter" type="Spring.NmsQuickStart.Common.Converters.XmlMessageConverter, Spring.NmsQuickStart.Common">
|
||||
<property name="TypeMapper" ref="TypeMapper"/>
|
||||
</object>
|
||||
|
||||
@@ -323,11 +340,11 @@
|
||||
<title>Messaging Infrastructure</title>
|
||||
|
||||
<para>The implementations of the gateway interfaces inherit from Spring's
|
||||
helper class <classname>NmsGatewaySupport</classname> in order to get easy
|
||||
helper class <literal>NmsGatewaySupport</literal> in order to get easy
|
||||
access to a NmsTemplate for sending. The implementation of the
|
||||
<classname>IStockService</classname> interface is shown below</para>
|
||||
<literal>IStockService</literal> interface is shown below</para>
|
||||
|
||||
<programlisting> public class NmsStockServiceGateway : NmsGatewaySupport, IStockService
|
||||
<programlisting language="csharp"> public class NmsStockServiceGateway : NmsGatewaySupport, IStockService
|
||||
{
|
||||
private IDestination defaultReplyToQueue;
|
||||
|
||||
@@ -347,7 +364,7 @@
|
||||
}
|
||||
}</programlisting>
|
||||
|
||||
<para>The <classname>Send</classname> method is using NmsTemplate's
|
||||
<para>The <literal>Send</literal> method is using NmsTemplate's
|
||||
<literal>ConvertAndSendWithDelegate(object obj,
|
||||
MessagePostProcessorDelegate messagePostProcessorDelegate)</literal>
|
||||
method. The anonymous delegate allows you to modify the message
|
||||
@@ -357,12 +374,13 @@
|
||||
logic to the converted message.</para>
|
||||
|
||||
<para>The object definition for the
|
||||
<classname>NmsStockServiceGateway</classname> is shown below along with
|
||||
<literal>NmsStockServiceGateway</literal> is shown below along with
|
||||
its dependent object definitions of NmsTemplate and the
|
||||
ConnectionFactory.</para>
|
||||
|
||||
<para><programlisting> <object name="StockServiceGateway" type="Spring.NmsQuickStart.Client.Gateways.NmsStockServiceGateway, Spring.NmsQuickStart.Client">
|
||||
<property name="NmsTemplate" ref="<emphasis role="bold">NmsTemplate</emphasis>"/>
|
||||
<para>
|
||||
<programlisting language="myxml"> <object name="StockServiceGateway" type="Spring.NmsQuickStart.Client.Gateways.NmsStockServiceGateway, Spring.NmsQuickStart.Client">
|
||||
<property name="NmsTemplate" ref="NmsTemplate"/>
|
||||
<property name="DefaultReplyToQueue">
|
||||
<object type="Apache.NMS.ActiveMQ.Commands.ActiveMQQueue, Apache.NMS.ActiveMQ">
|
||||
<constructor-arg value="APP.STOCK.JOE"/>
|
||||
@@ -370,32 +388,32 @@
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object name="<emphasis role="bold">NmsTemplate</emphasis>" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
|
||||
<property name="ConnectionFactory" ref="<emphasis role="bold">ConnectionFactory</emphasis>"/>
|
||||
<object name="NmsTemplate" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
|
||||
<property name="ConnectionFactory" ref="ConnectionFactory"/>
|
||||
<property name="DefaultDestinationName" value="APP.STOCK.REQUEST"/>
|
||||
<property name="MessageConverter" ref="XmlMessageConverter"/>
|
||||
</object>
|
||||
|
||||
<object id="<emphasis role="bold">ConnectionFactory</emphasis>" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
|
||||
<object id="ConnectionFactory" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
|
||||
<constructor-arg index="0" value="tcp://localhost:61616"/>
|
||||
</object></programlisting>In this example the 'raw'
|
||||
<classname>Apache.NMS.ActiveMQ.ConnectionFactory </classname>connection
|
||||
<literal>Apache.NMS.ActiveMQ.ConnectionFactory </literal>connection
|
||||
factory was used. It would be more efficient resource wise to use Spring's
|
||||
<classname>CachingConnectionFactory</classname> wrapper class so that
|
||||
<literal>CachingConnectionFactory</literal> wrapper class so that
|
||||
connections will not be open and closed for each message send as well as
|
||||
allowing for the caching of other intermediate NMS API objects such as
|
||||
sessions and message producers.</para>
|
||||
|
||||
<para>A similar configuration is used on the server to configure the class
|
||||
<classname>Spring.NmsQuickStart.Server.Gateways.MarketDataServiceGateway
|
||||
</classname>that implements the <classname>IMarketDataService</classname>
|
||||
<literal>Spring.NmsQuickStart.Server.Gateways.MarketDataServiceGateway
|
||||
</literal>that implements the <literal>IMarketDataService</literal>
|
||||
interface.</para>
|
||||
|
||||
<para>Since the client is also a consumer of messages, on the topic
|
||||
APP.STOCK.MARKETDATA and the queue APP.STOCK.JOE (for Trader Joe!), two
|
||||
message listener containers are defined as shown below.</para>
|
||||
|
||||
<programlisting> <nms:listener-container connection-factory="ConnectionFactory">
|
||||
<programlisting language="myxml"> <nms:listener-container connection-factory="ConnectionFactory">
|
||||
<nms:listener ref="MessageListenerAdapter" destination="APP.STOCK.JOE" />
|
||||
<nms:listener ref="MessageListenerAdapter" destination="APP.STOCK.MARKETDATA" pubsub-domain="true"/>
|
||||
</nms:listener-container></programlisting>
|
||||
@@ -410,7 +428,7 @@
|
||||
APP.STOCK.REQUEST but set the concurrency property to 10 so that 10
|
||||
threads will be consuming messages from the queue.</para>
|
||||
|
||||
<programlisting> <nms:listener-container connection-factory="ConnectionFactory" concurrency="<emphasis
|
||||
<programlisting language="myxml"> <nms:listener-container connection-factory="ConnectionFactory" concurrency="<emphasis
|
||||
role="bold">10</emphasis>">
|
||||
<nms:listener ref="MessageListenerAdapter" destination="APP.STOCK.REQUEST" />
|
||||
</nms:listener-container></programlisting>
|
||||
|
||||
Reference in New Issue
Block a user