Files
hb_roma/src/main/java/com/njcn/roma/client/ClientTest.java
2024-07-01 14:56:58 +08:00

46 lines
1.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//package com.njcn.roma.client;
//
//import com.huawei.it.eip.ump.client.consumer.ConsumeStatus;
//import com.huawei.it.eip.ump.client.consumer.Consumer;
//import com.huawei.it.eip.ump.client.listener.MessageListener;
//import com.huawei.it.eip.ump.common.exception.UmpException;
//import com.huawei.it.eip.ump.common.message.Message;
//
//import java.io.UnsupportedEncodingException;
//
///**
// * roma
// *
// * @author cdf
// * @date 2024/6/6
// */
//public class ClientTest {
// public static void main(String[] args) throws UmpException {
// Consumer consumer = new Consumer();
// consumer.setUmpNamesrvUrls("25.36.190.3:19776"); // 设置统一消息
// //平台的服务器地址
// consumer.setAppId("X_DNZLXT"); // 设置客户端账号
// consumer.setAppSecret("IoKU7u47seGwzO4CqGmCaQ=="); // 设置客户端密钥
// consumer.setTopic("T_DNZLXT");// 设置 Topic Name
// consumer.setTags("*"); // 设置订阅消息的标签,可以指定消
// //费某一类型的消息,默认*表示消费所有类型的消息
// consumer.setEncryptTransport(false);// 设置是否需要加密传输
// consumer.subscribe(new MessageListener() {
// public ConsumeStatus consume(Message message) {
// // 消费消息的业务逻辑
// try {
// System.out.println("Receive: " + new String(message.getBody(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// throw new RuntimeException(e);
// }
// // 正常接收到消息后,请务必返回 CONSUME_SUCCESS只有在业务处理失败才返回RECONSUME_LATER
// return ConsumeStatus.CONSUME_SUCCESS;
// }
// });
// consumer.start();
// // 启动消费者,建议在应用程序关闭时执行
// //consumer.shutdown();
// //关闭此消费者。
// }
//}