本文整理汇总了Java中com.alibaba.rocketmq.common.conflict.PackageConflictDetect类的典型用法代码示例。如果您正苦于以下问题:Java PackageConflictDetect类的具体用法?Java PackageConflictDetect怎么用?Java PackageConflictDetect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PackageConflictDetect类属于com.alibaba.rocketmq.common.conflict包,在下文中一共展示了PackageConflictDetect类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.alibaba.rocketmq.common.conflict.PackageConflictDetect; //导入依赖的package包/类
public void start() throws MQClientException {
PackageConflictDetect.detectFastjson();
synchronized (this) {
switch (this.serviceState) {
case CREATE_JUST:
this.serviceState = ServiceState.START_FAILED;
// If not specified,looking address from name server
if (null == this.clientConfig.getNamesrvAddr()) {
this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
}
// Start request-response channel
this.mQClientAPIImpl.start();
// Start various schedule tasks
this.startScheduledTask();
// Start pull service
this.pullMessageService.start();
// Start rebalance service
this.rebalanceService.start();
// Start push service
this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
log.info("the client factory [{}] start OK", this.clientId);
this.serviceState = ServiceState.RUNNING;
break;
case RUNNING:
break;
case SHUTDOWN_ALREADY:
break;
case START_FAILED:
throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
default:
break;
}
}
}
示例2: start
import com.alibaba.rocketmq.common.conflict.PackageConflictDetect; //导入依赖的package包/类
/**
* 启动客户端代理
*
* @throws MQClientException
*/
public void start() throws MQClientException {
/**
* 检查fastjson版本是否有问题
*/
PackageConflictDetect.detectFastjson();
synchronized (this) {
switch (this.serviceState) {
case CREATE_JUST:
this.serviceState = ServiceState.START_FAILED;
/**
* 如果没有指定Nameserver的地址,则通过指定的http服务获取
*/
// If not specified,looking address from name server
if (null == this.clientConfig.getNamesrvAddr()) {
//这里设置了clientConfig的namesr字段,但是没有返回去设置consumer的,所以启动之后
//如果通过consumer.getNamesrvaddr()获取是获取不到的
this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
}
/**
* 启动与broker和nameserv的通信实例
*/
// Start request-response channel
this.mQClientAPIImpl.start();
// Start various schedule tasks
this.startScheduledTask();
// Start pull service
this.pullMessageService.start();
// Start rebalance service
this.rebalanceService.start();
/**
* 为什么消费者端也要启动一个Producer?
* 因为当消费失败的时候,需要把消息发回去
*/
// Start push service
this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
//启动成功
log.info("the client factory [{}] start OK", this.clientId);
this.serviceState = ServiceState.RUNNING;
break;
case RUNNING:
break;
case SHUTDOWN_ALREADY:
break;
case START_FAILED:
throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
default:
break;
}
}
}