CafeDemo now demonstrates the <concurrency-interceptor/>.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user