added comments
This commit is contained in:
@@ -28,6 +28,7 @@ public class Order {
|
||||
|
||||
private List<OrderItem> orderItems = new ArrayList<OrderItem>();
|
||||
|
||||
/** the order number used for tracking */
|
||||
private int number;
|
||||
|
||||
// Default constructor required by Jackson Java JSON-processor
|
||||
|
||||
@@ -29,6 +29,7 @@ public class OrderItem {
|
||||
|
||||
private boolean iced = false;
|
||||
|
||||
/** the order this item is tied to */
|
||||
private int orderNumber;
|
||||
|
||||
// Default constructor required by Jackson Java JSON-processor
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<!-- rabbit connection factory, rabbit template, and rabbit admin -->
|
||||
<import resource="classpath:META-INF/spring/integration/amqp/cafeDemo-amqp-config-xml.xml" />
|
||||
|
||||
<!-- To receive an AMQP Message from a Queue, and respond to its reply-to address, configure an inbound-gateway. -->
|
||||
<int-amqp:inbound-gateway
|
||||
id="coldDrinksBarista"
|
||||
request-channel="coldJsonDrinks"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<!-- rabbit connection factory, rabbit template, and rabbit admin -->
|
||||
<import resource="classpath:META-INF/spring/integration/amqp/cafeDemo-amqp-config-xml.xml" />
|
||||
|
||||
<!-- To receive an AMQP Message from a Queue, and respond to its reply-to address, configure an inbound-gateway. -->
|
||||
<int-amqp:inbound-gateway
|
||||
id="hotDrinksBarista"
|
||||
request-channel="hotJsonDrinks"
|
||||
|
||||
@@ -10,14 +10,23 @@
|
||||
http://www.springframework.org/schema/rabbit
|
||||
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
|
||||
|
||||
<!-- Obtain a connection to the RabbitMQ via cloudfoundry-runtime: -->
|
||||
<!--
|
||||
<cloud:rabbit-connection-factory id="rabbitConnectionFactory"/>
|
||||
-->
|
||||
|
||||
<!-- connect to the local broker using the default user name and password -->
|
||||
<bean id="rabbitConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
|
||||
<constructor-arg value="localhost"/>
|
||||
<property name="username" value="guest"/>
|
||||
<property name="password" value="guest"/>
|
||||
</bean>
|
||||
|
||||
<rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory" reply-timeout="10000"/>
|
||||
<!-- Set up the AmqpTemplate/RabbitTemplate: -->
|
||||
<rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory" reply-timeout="10000"/>
|
||||
|
||||
<!-- Request that queues, exchanges and bindings be automatically
|
||||
declared on the broker: -->
|
||||
<rabbit:admin connection-factory="rabbitConnectionFactory" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
<!-- rabbit connection factory, rabbit template, and rabbit admin -->
|
||||
<import resource="classpath:META-INF/spring/integration/amqp/cafeDemo-amqp-config-xml.xml" />
|
||||
|
||||
<!-- intercept messages on these channels while still allowing them to continue -->
|
||||
<int:wire-tap channel="logger" pattern="orders,coldDrinks,hotDrinks,preparedDrinks,deliveries"/>
|
||||
<int:logging-channel-adapter id="logger" log-full-message="true" level="INFO"/>
|
||||
|
||||
<!-- To receive AMQP Messages from a Queue, configure an inbound-channel-adapter -->
|
||||
<int-amqp:inbound-channel-adapter queue-names="new-orders" channel="jsonOrders" connection-factory="rabbitConnectionFactory" acknowledge-mode="AUTO" />
|
||||
|
||||
<int:json-to-object-transformer id="json-to-order" input-channel="jsonOrders" output-channel="preOrders" type="org.springframework.integration.samples.cafe.Order" />
|
||||
@@ -49,7 +51,8 @@
|
||||
<int:channel id="hotDrinks">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
|
||||
<!-- To send AMQP Messages to an Exchange and receive back a response from a remote client, configure an outbound-gateway -->
|
||||
<int-amqp:outbound-gateway
|
||||
id="coldDrinksBarista"
|
||||
request-channel="coldDrinks"
|
||||
@@ -58,6 +61,7 @@
|
||||
routing-key="drink.cold"
|
||||
amqp-template="amqpTemplate" />
|
||||
|
||||
<!-- To send AMQP Messages to an Exchange and receive back a response from a remote client, configure an outbound-gateway -->
|
||||
<int-amqp:outbound-gateway
|
||||
id="hotDrinksBarista"
|
||||
request-channel="hotDrinks"
|
||||
@@ -84,6 +88,7 @@
|
||||
|
||||
<int:channel id="jsonDeliveries" />
|
||||
|
||||
<!-- To send AMQP Messages to an Exchange, configure an outbound-channel-adapter. -->
|
||||
<int-amqp:outbound-channel-adapter
|
||||
id="deliveredOrders"
|
||||
channel="jsonDeliveries"
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
<int:channel id="jsonNewOrders" />
|
||||
|
||||
<!-- To send AMQP Messages to an Exchange, configure an outbound-channel-adapter. -->
|
||||
<int-amqp:outbound-channel-adapter
|
||||
channel="jsonNewOrders"
|
||||
exchange-name="cafe-orders"
|
||||
|
||||
@@ -12,22 +12,27 @@
|
||||
|
||||
<gateway id="cafe" service-interface="org.springframework.integration.samples.cafe.Cafe"/>
|
||||
|
||||
<!-- each order has a collection of order items that is split apart to be processed -->
|
||||
<channel id="orders"/>
|
||||
<splitter input-channel="orders" expression="payload.items" output-channel="drinks"/>
|
||||
|
||||
<!-- The router sends different drink orders on different paths -->
|
||||
<channel id="drinks"/>
|
||||
<router input-channel="drinks" expression="payload.iced ? 'coldDrinks' : 'hotDrinks'"/>
|
||||
|
||||
<!-- individual order items are processed by the barista -->
|
||||
<channel id="coldDrinks">
|
||||
<queue capacity="10"/>
|
||||
</channel>
|
||||
<service-activator input-channel="coldDrinks" ref="barista" method="prepareColdDrink" output-channel="preparedDrinks"/>
|
||||
|
||||
<!-- individual order items are processed by the barista -->
|
||||
<channel id="hotDrinks">
|
||||
<queue capacity="10"/>
|
||||
</channel>
|
||||
<service-activator input-channel="hotDrinks" ref="barista" method="prepareHotDrink" output-channel="preparedDrinks"/>
|
||||
|
||||
<!-- drink order items are aggregated in a call to the waiter -->
|
||||
<channel id="preparedDrinks"/>
|
||||
<aggregator input-channel="preparedDrinks" method="prepareDelivery" output-channel="deliveries">
|
||||
<beans:bean class="org.springframework.integration.samples.cafe.xml.Waiter"/>
|
||||
|
||||
Reference in New Issue
Block a user