架构
```java
@Configuration
public class WareMessageConfig {
@Bean
public Exchange stockEventExchange() {
return new TopicExchange("stock-event-exchange", true, false, null);
}
@Bean
public Queue stockDelayQueue() {
Map<String, Object> arguments = new HashMap<>();
arguments.put("x-dead-letter-exchange", "stock-event-exchange");
arguments.put("x-dead-letter-routing-key", "stock-release-#");
arguments.put("x-message-ttl", 10000);
return new Queue("stock-delay-queue", true, false, false, arguments);
}
@Bean
public Queue stockReleaseStockQueue() {
return new Queue("stock-release-stock-queue", true, false, false, null);
}
@Bean
public Binding stockLock() {
return new Binding("stock-delay-queue",
Binding.DestinationType.QUEUE,
"stock-event-exchange",
"stock-lock",
null);
}
@Bean
public Binding stockRelease() {
return new Binding("stock-release-stock-queue",
Binding.DestinationType.QUEUE,
"stock-event-exchange",
"stock-release-#",
null);
}
}
```
```java
@Configuration
public class OrderMessageConfig {
@Bean
public Exchange orderEventExchange() {
return new TopicExchange("order-event-exchange", true, false, null);
}
@Bean
public Queue orderDelayQueue() {
Map<String, Object> arguments = new HashMap<>();
arguments.put("x-dead-letter-exchange", "order-event-exchange");
arguments.put("x-dead-letter-routing-key", "order-release-order");
arguments.put("x-message-ttl", 60000);
return new Queue("order-delay-queue", true, false, false, arguments);
}
@Bean
public Queue orderReleaseOrderQueue() {
return new Queue("order-release-order-queue", true, false, false, null);
}
@Bean
public Binding orderCreateOrder() {
return new Binding("order-delay-queue",
Binding.DestinationType.QUEUE,
"order-event-exchange",
"order-create-order", null);
}
@Bean
public Binding orderReleaseOrder() {
return new Binding("order-release-order-queue",
Binding.DestinationType.QUEUE,
"order-event-exchange",
"order-release-order", null);
}
}
```