CafeDemo now demonstrates the <concurrency-interceptor/>.

This commit is contained in:
Mark Fisher
2008-07-05 18:53:46 +00:00
parent 6cb6347b82
commit 63c8c2a30f
2 changed files with 10 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
@Component
public class Barista {
private long hotDrinkDelay = 2000;
private long hotDrinkDelay = 5000;
private long coldDrinkDelay = 1000;
@@ -46,19 +46,21 @@ public class Barista {
public void prepareHotDrink(Drink drink) {
try {
Thread.sleep(this.hotDrinkDelay);
System.out.println(Thread.currentThread().getName()
+ " prepared hot drink #" + hotDrinkCounter.incrementAndGet() + ": " + drink);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println("prepared hot drink #" + hotDrinkCounter.incrementAndGet() + ": " + drink);
}
public void prepareColdDrink(Drink drink) {
try {
Thread.sleep(this.coldDrinkDelay);
System.out.println(Thread.currentThread().getName()
+ " prepared cold drink #" + coldDrinkCounter.incrementAndGet() + ": " + drink);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println("prepared cold drink #" + coldDrinkCounter.incrementAndGet() + ": " + drink);
}
}

View File

@@ -21,7 +21,11 @@
<channel id="hotDrinks"/>
<handler-endpoint input-channel="coldDrinks" handler="barista" method="prepareColdDrink"/>
<handler-endpoint input-channel="hotDrinks" handler="barista" method="prepareHotDrink"/>
<handler-endpoint input-channel="hotDrinks" handler="barista" method="prepareHotDrink">
<interceptors>
<concurrency-interceptor max="5"/>
</interceptors>
</handler-endpoint>
<beans:bean id="cafe" class="org.springframework.integration.samples.cafe.Cafe">
<beans:property name="orderChannel" ref="orders"/>