Cafe demo now uses a gateway proxy.
This commit is contained in:
@@ -16,29 +16,18 @@
|
||||
|
||||
package org.springframework.integration.samples.cafe;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
|
||||
/**
|
||||
* The entry point for Cafe Demo. When the '<code>placeOrder</code>'
|
||||
* method is invoked, it passes the {@link Order} as the payload of a
|
||||
* The entry point for Cafe Demo. The demo's main() method invokes the
|
||||
* '<code>placeOrder</code>' method on a generated MessagingGateway proxy.
|
||||
* The gateway then passes the {@link Order} as the payload of a
|
||||
* {@link org.springframework.integration.message.Message} to the
|
||||
* 'orderChannel'. The channel reference is configured in the "cafe" bean
|
||||
* definition within 'cafeDemo.xml'.
|
||||
* configured <em>requestChannel</em>. The channel reference ('orders')
|
||||
* is configured in the 'cafeDemo.xml' file.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class Cafe {
|
||||
public interface Cafe {
|
||||
|
||||
private MessageChannel orderChannel;
|
||||
|
||||
|
||||
public void setOrderChannel(MessageChannel orderChannel) {
|
||||
this.orderChannel = orderChannel;
|
||||
}
|
||||
|
||||
public void placeOrder(Order order) {
|
||||
this.orderChannel.send(MessageBuilder.fromPayload(order).build());
|
||||
}
|
||||
void placeOrder(Order order);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.integration.samples.cafe.Drink;
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@MessageEndpoint
|
||||
public class DeliveryAssembler {
|
||||
public class Waiter {
|
||||
|
||||
@Aggregator(inputChannel = "preparedDrinks", outputChannel = "deliveries", timeout = 5 * 60 * 1000)
|
||||
public Delivery prepareDelivery(List<Drink> drinks) {
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.samples.cafe.annotation"/>
|
||||
|
||||
<gateway id="cafe" request-channel="orders" service-interface="org.springframework.integration.samples.cafe.Cafe"/>
|
||||
|
||||
<channel id="orders"/>
|
||||
<channel id="drinks"/>
|
||||
|
||||
@@ -28,10 +30,6 @@
|
||||
|
||||
<channel id="preparedDrinks"/>
|
||||
|
||||
<beans:bean id="cafe" class="org.springframework.integration.samples.cafe.Cafe">
|
||||
<beans:property name="orderChannel" ref="orders"/>
|
||||
</beans:bean>
|
||||
|
||||
<stdout-channel-adapter id="deliveries"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.integration.samples.cafe.Drink;
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class DeliveryAssembler {
|
||||
public class Waiter {
|
||||
|
||||
public Delivery prepareDelivery(List<Drink> drinks) {
|
||||
return new Delivery(drinks);
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
<message-bus/>
|
||||
|
||||
<gateway id="cafe" request-channel="orders" service-interface="org.springframework.integration.samples.cafe.Cafe"/>
|
||||
|
||||
<channel id="orders"/>
|
||||
<splitter input-channel="orders" ref="orderSplitter" method="split" output-channel="drinks"/>
|
||||
|
||||
@@ -27,20 +29,16 @@
|
||||
<service-activator input-channel="hotDrinks" ref="barista" method="prepareHotDrink" output-channel="preparedDrinks"/>
|
||||
|
||||
<channel id="preparedDrinks"/>
|
||||
<aggregator input-channel="preparedDrinks" ref="deliveryAssembler" method="prepareDelivery" output-channel="deliveries"/>
|
||||
<aggregator input-channel="preparedDrinks" ref="waiter" method="prepareDelivery" output-channel="deliveries"/>
|
||||
|
||||
<stdout-channel-adapter id="deliveries"/>
|
||||
|
||||
<beans:bean id="cafe" class="org.springframework.integration.samples.cafe.Cafe">
|
||||
<beans:property name="orderChannel" ref="orders"/>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="orderSplitter" class="org.springframework.integration.samples.cafe.xml.OrderSplitter"/>
|
||||
|
||||
<beans:bean id="drinkRouter" class="org.springframework.integration.samples.cafe.xml.DrinkRouter"/>
|
||||
|
||||
<beans:bean id="barista" class="org.springframework.integration.samples.cafe.xml.Barista"/>
|
||||
|
||||
<beans:bean id="deliveryAssembler" class="org.springframework.integration.samples.cafe.xml.DeliveryAssembler"/>
|
||||
<beans:bean id="waiter" class="org.springframework.integration.samples.cafe.xml.Waiter"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
Reference in New Issue
Block a user