| | |
| | | package cc.mrbird.febs.job; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import com.huobi.client.SubscriptionClient; |
| | | import com.huobi.client.SubscriptionOptions; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | |
| | | /** |
| | | * @author |
| | | * @date 2022-03-24 |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | public class NewPriceUpdateJob{ |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | @PostConstruct |
| | | public void initNewPriceUpdate() { |
| | | log.info("#最新价更新启动#"); |
| | | redisUtils.set(AppContants.REDIS_KEY_CHANGE_FEE, 30); |
| | | SubscriptionOptions subscriptionOptions = new SubscriptionOptions(); |
| | | subscriptionOptions.setConnectionDelayOnFailure(5); |
| | | subscriptionOptions.setUri("wss://api.hadax.com/ws"); |
| | | SubscriptionClient subscriptionClient = SubscriptionClient.create("", "", subscriptionOptions); |
| | | subscriptionClient.subscribeTradeEvent("ethusdt", tradeEvent -> { |
| | | redisUtils.set(AppContants.REDIS_KEY_ETH_NEW_PRICE, tradeEvent.getTradeList().get(0).getPrice()); |
| | | }); |
| | | } |
| | | } |
| | | //package cc.mrbird.febs.job; |
| | | // |
| | | //import cc.mrbird.febs.common.contants.AppContants; |
| | | //import cc.mrbird.febs.common.utils.RedisUtils; |
| | | //import com.huobi.client.SubscriptionClient; |
| | | //import com.huobi.client.SubscriptionOptions; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import javax.annotation.PostConstruct; |
| | | // |
| | | ///** |
| | | // * @author |
| | | // * @date 2022-03-24 |
| | | // **/ |
| | | //@Slf4j |
| | | //@Component |
| | | //public class NewPriceUpdateJob{ |
| | | // |
| | | // @Autowired |
| | | // private RedisUtils redisUtils; |
| | | // |
| | | // @PostConstruct |
| | | // public void initNewPriceUpdate() { |
| | | //// log.info("#最新价更新启动#"); |
| | | //// redisUtils.set(AppContants.REDIS_KEY_CHANGE_FEE, 30); |
| | | //// SubscriptionOptions subscriptionOptions = new SubscriptionOptions(); |
| | | //// subscriptionOptions.setConnectionDelayOnFailure(5); |
| | | //// subscriptionOptions.setUri("wss://api.hadax.com/ws"); |
| | | //// SubscriptionClient subscriptionClient = SubscriptionClient.create("", "", subscriptionOptions); |
| | | //// subscriptionClient.subscribeTradeEvent("ethusdt", tradeEvent -> { |
| | | //// redisUtils.set(AppContants.REDIS_KEY_ETH_NEW_PRICE, tradeEvent.getTradeList().get(0).getPrice()); |
| | | //// }); |
| | | // } |
| | | //} |