最近在对接饿了么的接口。官方推荐用全双工消息推送。我看了下demo的意思是在main方法启动起来就可以了。所以我将他整合到Spring的时候,就在Spring初始化的时候执行init方法执行那一段代码。但是问题很严重,老是收不到消息,不知道什么原因!望大牛赐教!
public static void main(String[] args) {
Account account = new Account("your key", "your sercret");
List accounts = new ArrayList();
accounts.add(account);
Config config = new Config(accounts,
new BusinessHandle() {
@Override
public boolean onMessage(String message) {
//你的业务消息处理,推荐直接落地存储,不要耦合过重业务
return true;
}
},
new ElemeSdkLogger() {
@Override
public void info(String message) {
//your info log 处理
}
@Override
public void error(String message) {
//your error log 处理
}
}
);
try {
Bootstrap.start(config);
} catch (UnableConnectionException e) {
e.printStackTrace();
}
}