MqTest.java
1.07 KB
package cn.runsa.crmapp.goods;
import cn.runsa.crmapp.base.Constants;
import cn.runsa.crmapp.base.mq.BaseService;
import cn.runsa.crmapp.base.mq.MNSCredential;
import cn.runsa.crmapp.goods.open.auto.vo.AutoCustomerCar;
import com.alibaba.fastjson.JSON;
import com.aliyun.mns.client.CloudAccount;
import com.aliyun.mns.client.CloudQueue;
import com.aliyun.mns.client.MNSClient;
import com.aliyun.mns.model.Message;
public class MqTest {
public static void main(String[] args) {
System.setProperty(Constants.CONSTANTS_SERVER_CONFIG_PATH, "F:/server.properties");
CloudAccount account = new CloudAccount(
MNSCredential.getMNSAccessKeyId(),
MNSCredential.getMNSAccessKeySecret(),
MNSCredential.getMNSAccountEndpoint());
MNSClient client = account.getMNSClient();
CloudQueue q = client.getQueueRef("auto-order-settle-record-queue");
Message msg = q.popMessage();
String data = BaseService.unGZIP(msg.getMessageBodyAsBytes());
System.err.println(data);
AutoCustomerCar c = JSON.parseObject(data, AutoCustomerCar.class);
System.err.println(c);
client.close();
}
}