From d174d6963d62b3bd176f9e7ba3cf0d7f75a91b69 Mon Sep 17 00:00:00 2001 From: zainali5120 <512061637@qq.com> Date: Wed, 16 Sep 2020 16:03:22 +0800 Subject: [PATCH] 撮合交易代码提交 --- src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java | 98 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 88 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java index 7be7a45..1389b69 100644 --- a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java +++ b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java @@ -21,36 +21,46 @@ @Configuration public class RabbitMqConfig { - public static final String EXCHANGE_ONE = "excoin-exchange-one"; + public static final String EXCHANGE_ONE = "biue-exchange-one"; public static final String QUEUE_TEST = "test-queue"; public static final String ROUTING_KEY_TEST = "test-routingKey"; - public static final String EXCHANGE_A = "biyi-exchange-A"; + public static final String EXCHANGE_A = "biue-exchange-A"; + + /** + * 撮合交易 + */ + public static final String EXCHANGE_B = "biue-exchange-B"; // 开多止盈队列 - public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO"; + public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO_NEW"; // 开空止盈队列 - public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO"; + public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO_NEW"; // 开多止损队列 - public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS"; + public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS_NEW"; // 开空止损队列 - public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS"; + public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS_NEW"; // 限价委托 public static final String QUEUE_LIMIT = "QUEUE_LIMIT_NEW"; // 爆仓队列 - public static final String QUEUE_COINOUT = "QUEUE_COINOUT"; + public static final String QUEUE_COINOUT = "QUEUE_COINOUT_NEW"; //价格操作 - public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE"; + public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE_NEW"; // 平仓队列 - public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE"; + public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE_NEW"; + // 盘口队列 + public static final String QUEUE_TRADE_PLATE = "QUEUE_TRADE_PLATE"; + + // 处理交易 + public static final String QUEUE_HANDLE_TRADE = "QUEUE_HANDLE_TRADE"; // 开多止盈路由键 @@ -72,6 +82,12 @@ public static final String ROUTINGKEY_PRICEOPERATE = "ROUTINGKEY_PRICEOPERATE"; // 平仓路由 public static final String ROUTINGKEY_CLOSETRADE = "ROUTINGKEY_CLOSETRADE"; + + // 盘口理路由 + public static final String ROUTINGKEY_TRADE_PLATE = "ROUTINGKEY_TRADE_PLATE"; + + // 交易订单处理 + public static final String ROUTINGKEY_HANDLE_TRADE = "ROUTINGKEY_HANDLE_TRADE"; @Resource private ConnectionFactory connectionFactory; @@ -96,6 +112,7 @@ return new DirectExchange(EXCHANGE_ONE); } + @Bean public Queue testQueue() { return new Queue(QUEUE_TEST, true); @@ -118,9 +135,9 @@ } - /** * 开多止盈队列 + * * @return */ @Bean @@ -131,6 +148,7 @@ /** * 开空止盈队列 + * * @return */ @Bean @@ -141,6 +159,7 @@ /** * 开多止损 + * * @return */ @Bean @@ -151,6 +170,7 @@ /** * 开空止损 + * * @return */ @Bean @@ -161,6 +181,7 @@ /** * 限价委托 + * * @return */ @Bean @@ -171,6 +192,7 @@ /** * 爆仓 + * * @return */ @Bean @@ -180,6 +202,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -189,6 +212,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -197,9 +221,30 @@ } + /** + * 盘口推送 + * + * @return + */ + @Bean + public Queue queuePlateTrade() { + return new Queue(QUEUE_TRADE_PLATE, true); + } + + /** + * 交易订单处理 + * + * @return + */ + @Bean + public Queue queueHandleTrade() { + return new Queue(QUEUE_HANDLE_TRADE, true); + } + /** * 开多止盈 + * * @return */ @Bean @@ -209,6 +254,7 @@ /** * 开空止盈 + * * @return */ @Bean @@ -218,6 +264,7 @@ /** * 开多止损 + * * @return */ @Bean @@ -227,6 +274,7 @@ /** * 开空止损 + * * @return */ @Bean @@ -237,6 +285,7 @@ /** * 委托 + * * @return */ @Bean @@ -247,6 +296,7 @@ /** * 爆仓 + * * @return */ @Bean @@ -257,6 +307,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -266,6 +317,7 @@ /** * 平仓绑定 + * * @return */ @Bean @@ -273,4 +325,30 @@ return BindingBuilder.bind(queueCloseTrade()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_CLOSETRADE); } + + @Bean + public DirectExchange matchTradeExchange() { + return new DirectExchange(EXCHANGE_B); + } + + /** + * 盘口变化绑定 + * + * @return + */ + @Bean + public Binding bindingPlateTrade() { + return BindingBuilder.bind(queuePlateTrade()).to(matchTradeExchange()).with(RabbitMqConfig.ROUTINGKEY_TRADE_PLATE); + } + + /** + * 交易订单处理 + * + * @return + */ + @Bean + public Binding bindingHandleTrade() { + return BindingBuilder.bind(queueHandleTrade()).to(matchTradeExchange()).with(RabbitMqConfig.ROUTINGKEY_HANDLE_TRADE); + } + } -- Gitblit v1.9.1