|
|
@ -43,8 +43,8 @@ public class HrmRocketmqServlet extends HttpServlet {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
isMainIp = isMainIp();//计算是否为集群中的主节点
|
|
|
|
isMainIp = isMainIp();//计算是否为集群中的主节点
|
|
|
|
isSampleMode = isSampleMode();//判断是否为单机
|
|
|
|
isSampleMode = isSampleMode();//判断是否为单机
|
|
|
|
bb.writeLog("isMainIp:"+isMainIp);
|
|
|
|
bb.writeLog("isMainIp3:"+isMainIp);
|
|
|
|
bb.writeLog("isSampleMode:"+isSampleMode);
|
|
|
|
bb.writeLog("isSampleMode3:"+isSampleMode);
|
|
|
|
|
|
|
|
|
|
|
|
if(isSampleMode){
|
|
|
|
if(isSampleMode){
|
|
|
|
initData();
|
|
|
|
initData();
|
|
|
@ -70,8 +70,6 @@ public class HrmRocketmqServlet extends HttpServlet {
|
|
|
|
PropBean propBean = new PropBean();
|
|
|
|
PropBean propBean = new PropBean();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// String consumerGroup = propBean.getUfPropValueStatic("consumerGroup");
|
|
|
|
|
|
|
|
// bb.writeLog("consumerGroup:" + consumerGroup);
|
|
|
|
|
|
|
|
String hrmConsumerGroup = PropBean.getUfPropValue("hrmConsumerGroup");
|
|
|
|
String hrmConsumerGroup = PropBean.getUfPropValue("hrmConsumerGroup");
|
|
|
|
String hrmConsumerAddr = PropBean.getUfPropValue("hrmConsumerAddr");
|
|
|
|
String hrmConsumerAddr = PropBean.getUfPropValue("hrmConsumerAddr");
|
|
|
|
String hrmInstanceName = PropBean.getUfPropValue("hrmInstanceName");
|
|
|
|
String hrmInstanceName = PropBean.getUfPropValue("hrmInstanceName");
|
|
|
@ -80,14 +78,24 @@ public class HrmRocketmqServlet extends HttpServlet {
|
|
|
|
String hrmMQAuthPWD = PropBean.getUfPropValue("hrmMQAuthPWD");
|
|
|
|
String hrmMQAuthPWD = PropBean.getUfPropValue("hrmMQAuthPWD");
|
|
|
|
String hrmMQClusterName = PropBean.getUfPropValue("hrmMQClusterName");
|
|
|
|
String hrmMQClusterName = PropBean.getUfPropValue("hrmMQClusterName");
|
|
|
|
String hrmMQTenantID = PropBean.getUfPropValue("hrmMQTenantID");
|
|
|
|
String hrmMQTenantID = PropBean.getUfPropValue("hrmMQTenantID");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb.writeLog("hrmConsumerGroup:" + hrmConsumerGroup);
|
|
|
|
|
|
|
|
bb.writeLog("hrmConsumerAddr:" + hrmConsumerAddr);
|
|
|
|
|
|
|
|
bb.writeLog("hrmInstanceName:" + hrmInstanceName);
|
|
|
|
|
|
|
|
bb.writeLog("hrmSubExpr:" + hrmSubExpr);
|
|
|
|
|
|
|
|
bb.writeLog("hrmMQAuthID:" + hrmMQAuthID);
|
|
|
|
|
|
|
|
bb.writeLog("hrmMQAuthPWD:" + hrmMQAuthPWD);
|
|
|
|
|
|
|
|
bb.writeLog("hrmMQClusterName:" + hrmMQClusterName);
|
|
|
|
|
|
|
|
bb.writeLog("hrmMQTenantID:" + hrmMQTenantID);
|
|
|
|
|
|
|
|
|
|
|
|
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(hrmConsumerGroup);
|
|
|
|
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(hrmConsumerGroup);
|
|
|
|
// String namesrvAddr = propBean.getUfPropValueStatic("namesrvAddr");
|
|
|
|
// String namesrvAddr = propBean.getUfPropValueStatic("namesrvAddr");
|
|
|
|
// bb.writeLog("namesrvAddr:" + namesrvAddr);
|
|
|
|
|
|
|
|
consumer.setNamesrvAddr(hrmConsumerAddr);
|
|
|
|
consumer.setNamesrvAddr(hrmConsumerAddr);
|
|
|
|
// String instanceName = propBean.getUfPropValueStatic("instanceName");
|
|
|
|
// String instanceName = propBean.getUfPropValueStatic("instanceName");
|
|
|
|
// bb.writeLog("instanceName:" + instanceName);
|
|
|
|
// bb.writeLog("instanceName:" + instanceName);
|
|
|
|
consumer.setInstanceName(hrmInstanceName);
|
|
|
|
consumer.setInstanceName(hrmInstanceName);
|
|
|
|
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
|
|
|
|
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
|
|
|
|
// String topic = propBean.getUfPropValueStatic("topic");
|
|
|
|
// String topic = propBean.getUfPropValueStatic("topic");
|
|
|
|
// String subExpression = propBean.getUfPropValueStatic("subExpression");
|
|
|
|
// String subExpression = propBean.getUfPropValueStatic("subExpression");
|
|
|
|
// bb.writeLog("topic:" + topic);
|
|
|
|
// bb.writeLog("topic:" + topic);
|
|
|
@ -100,26 +108,59 @@ public class HrmRocketmqServlet extends HttpServlet {
|
|
|
|
// bb.writeLog("authpwd:" + authpwd);
|
|
|
|
// bb.writeLog("authpwd:" + authpwd);
|
|
|
|
// bb.writeLog("clustername:" + clustername);
|
|
|
|
// bb.writeLog("clustername:" + clustername);
|
|
|
|
// bb.writeLog("tenantid:" + tenantid);
|
|
|
|
// bb.writeLog("tenantid:" + tenantid);
|
|
|
|
|
|
|
|
|
|
|
|
consumer.subscribe(hrmInstanceName, hrmSubExpr);
|
|
|
|
consumer.subscribe(hrmInstanceName, hrmSubExpr);
|
|
|
|
consumer.setAuthID(hrmMQAuthID);
|
|
|
|
consumer.setAuthID(hrmMQAuthID);
|
|
|
|
consumer.setAuthPWD(hrmMQAuthPWD);
|
|
|
|
consumer.setAuthPWD(hrmMQAuthPWD);
|
|
|
|
consumer.setClusterName(hrmMQClusterName);
|
|
|
|
consumer.setClusterName(hrmMQClusterName);
|
|
|
|
consumer.setTenantID(hrmMQTenantID);
|
|
|
|
consumer.setTenantID(hrmMQTenantID);
|
|
|
|
|
|
|
|
|
|
|
|
consumer.setConsumeThreadMin(1);
|
|
|
|
// consumer.setConsumeThreadMin(1);
|
|
|
|
consumer.setConsumeThreadMax(1);
|
|
|
|
// consumer.setConsumeThreadMax(1);
|
|
|
|
consumer.setConsumeMessageBatchMaxSize(1);
|
|
|
|
// consumer.setConsumeMessageBatchMaxSize(1);
|
|
|
|
|
|
|
|
|
|
|
|
consumer.setMessageModel(MessageModel.BROADCASTING);
|
|
|
|
consumer.setMessageModel(MessageModel.CLUSTERING);
|
|
|
|
consumer.registerMessageListener(new HrmRocketMsgListener());
|
|
|
|
consumer.registerMessageListener(new HrmRocketMsgListener3());
|
|
|
|
consumer.start();
|
|
|
|
consumer.start();
|
|
|
|
bb.writeLog("Consumer88Started.");
|
|
|
|
bb.writeLog("Consumer88Started.");
|
|
|
|
|
|
|
|
|
|
|
|
} catch (MQClientException var13) {
|
|
|
|
} catch (MQClientException e) {
|
|
|
|
bb.writeLog("Consumer resource model initiated--MQClientException:" + var13);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("Consumer resource model initiated--MQClientException:" + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public void initData(){
|
|
|
|
|
|
|
|
// BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
// PropBean propBean = new PropBean();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("");
|
|
|
|
|
|
|
|
// consumer.setNamesrvAddr("");
|
|
|
|
|
|
|
|
// consumer.setInstanceName("");
|
|
|
|
|
|
|
|
// consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
|
|
|
|
|
|
|
|
// consumer.subscribe("", "");
|
|
|
|
|
|
|
|
// consumer.setAuthID("");
|
|
|
|
|
|
|
|
// consumer.setAuthPWD("");
|
|
|
|
|
|
|
|
// consumer.setClusterName("");
|
|
|
|
|
|
|
|
// consumer.setTenantID("");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//// consumer.setConsumeThreadMin(1);
|
|
|
|
|
|
|
|
//// consumer.setConsumeThreadMax(1);
|
|
|
|
|
|
|
|
//// consumer.setConsumeMessageBatchMaxSize(1);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// consumer.setMessageModel(MessageModel.CLUSTERING);
|
|
|
|
|
|
|
|
// consumer.registerMessageListener(new HrmRocketMsgListener3());
|
|
|
|
|
|
|
|
// consumer.start();
|
|
|
|
|
|
|
|
// bb.writeLog("Consumer9999Started.");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } catch (MQClientException var13) {
|
|
|
|
|
|
|
|
// bb.writeLog("Consumer resource model initiated--MQClientException:" + var13);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 实现 HttpServlet 的 doGet 方法,不作任何操作
|
|
|
|
* 实现 HttpServlet 的 doGet 方法,不作任何操作
|
|
|
|
* @param request
|
|
|
|
* @param request
|
|
|
|