技术标签: Spring Cloud Stream Cloud Stream spring cloud
通过Spring Cloud Stream解耦具体消息中间件,屏蔽掉不同中间件之间的差异,简化了消息中间件使用难度,便于切换不同的消息队列。带来这些便利的同时,也引入了不少问题,本文从源码角度结合实际使用场景分析异常Dispatcher has no subscribers for channel产生的原因以及解决方案
由报错信息可知,产生报错的位置在UnicastingDispatcher类的doDispatch方法,此方法是由MessageChannel的send方法调用的。从代码分析可知doDispatch方法会获取消息对应的处理器,如果没有处理器处理消息,则会报Dispatcher has no subscribers。接下来我们需要去找初始化消息处理器的地方
private boolean doDispatch(Message<?> message) {
if (tryOptimizedDispatch(message)) {
return true;
}
boolean success = false;
// 获取消息对应的处理器
Iterator<MessageHandler> handlerIterator = this.getHandlerIterator(message);
// 如果没有对应的处理器报错
if (!handlerIterator.hasNext()) {
throw new MessageDispatchingException(message, "Dispatcher has no subscribers");
}
List<RuntimeException> exceptions = new ArrayList<RuntimeException>();
while (!success && handlerIterator.hasNext()) {
MessageHandler handler = handlerIterator.next();
try {
handler.handleMessage(message);
success = true; // we have a winner.
}
catch (Exception e) {
@SuppressWarnings("deprecation")
RuntimeException runtimeException = wrapExceptionIfNecessary(message, e);
exceptions.add(runtimeException);
this.handleExceptions(exceptions, message, !handlerIterator.hasNext());
}
}
return success;
}
我们知道报错的原因是没有拿到消息的处理器,我们看一下getHandlerIterator方法获取处理器的逻辑。该方法会从this.getHandlers()获取处理器
private Iterator<MessageHandler> getHandlerIterator(Message<?> message) {
if (this.loadBalancingStrategy != null) {
return this.loadBalancingStrategy.getHandlerIterator(message, this.getHandlers());
}
return this.getHandlers().iterator();
}
查看getHandlers方法可知其获取的处理器其实是从OrderedAwareCopyOnWriteArraySet类型的属性handlers获取的,handlers的值是通过addHandler方法设置
protected Set<MessageHandler> getHandlers() {
return this.handlers.asUnmodifiableSet();
}
private final OrderedAwareCopyOnWriteArraySet<MessageHandler> handlers =
new OrderedAwareCopyOnWriteArraySet<MessageHandler>();
public synchronized boolean addHandler(MessageHandler handler) {
Assert.notNull(handler, "handler must not be null");
Assert.isTrue(this.handlers.size() < this.maxSubscribers, "Maximum subscribers exceeded");
boolean added = this.handlers.add(handler);
if (this.handlers.size() == 1) {
this.theOneHandler = handler;
}
else {
this.theOneHandler = null;
}
return added;
}
AbstractSubscribableChannel类的subscribe方法有调用addHandler方法,而subscribe方法调用的地方有很多,我们可以看到AbstractMessageChannelBinder类的doBindProducer方法中有去调用subscribe设置处理处理器。而doBindProducer实际工作就是在初始化发送消息的通道及绑定通道到对应消息中间件等事情
@Override
public boolean subscribe(MessageHandler handler) {
MessageDispatcher dispatcher = getRequiredDispatcher();
// 调用addHandler添加处理消息方法
boolean added = dispatcher.addHandler(handler);
adjustCounterIfNecessary(dispatcher, added ? 1 : 0);
return added;
}
public final Binding<MessageChannel> doBindProducer(final String destination, MessageChannel outputChannel,
final P producerProperties) throws BinderException {
Assert.isInstanceOf(SubscribableChannel.class, outputChannel,
"Binding is supported only for SubscribableChannel instances");
final MessageHandler producerMessageHandler;
final ProducerDestination producerDestination;
try {
producerDestination = this.provisioningProvider.provisionProducerDestination(destination,
producerProperties);
SubscribableChannel errorChannel = producerProperties.isErrorChannelEnabled()
? registerErrorInfrastructure(producerDestination) : null;
producerMessageHandler = createProducerMessageHandler(producerDestination, producerProperties,
errorChannel);
if (producerMessageHandler instanceof InitializingBean) {
((InitializingBean) producerMessageHandler).afterPropertiesSet();
}
}
catch (Exception e) {
if (e instanceof BinderException) {
throw (BinderException) e;
}
else if (e instanceof ProvisioningException) {
throw (ProvisioningException) e;
}
else {
throw new BinderException("Exception thrown while building outbound endpoint", e);
}
}
if (producerMessageHandler instanceof Lifecycle) {
((Lifecycle) producerMessageHandler).start();
}
postProcessOutputChannel(outputChannel, producerProperties);
// 调用subscribe方法设置处理器
((SubscribableChannel) outputChannel).subscribe(
new SendingHandler(producerMessageHandler, HeaderMode.embeddedHeaders
.equals(producerProperties.getHeaderMode()), this.headersToEmbed,
producerProperties.isUseNativeEncoding()));
Binding<MessageChannel> binding = new DefaultBinding<MessageChannel>(destination, null, outputChannel,
producerMessageHandler instanceof Lifecycle ? (Lifecycle) producerMessageHandler : null) {
@Override
public Map<String, Object> getExtendedInfo() {
return doGetExtendedInfo(destination, producerProperties);
}
@Override
public void afterUnbind() {
try {
destroyErrorInfrastructure(producerDestination);
if (producerMessageHandler instanceof DisposableBean) {
((DisposableBean) producerMessageHandler).destroy();
}
}
catch (Exception e) {
AbstractMessageChannelBinder.this.logger
.error("Exception thrown while unbinding " + toString(), e);
}
afterUnbindProducer(producerDestination, producerProperties);
}
};
doPublishEvent(new BindingCreatedEvent(binding));
return binding;
}
查看doBindProducer方法的调用方法,可以知道BindingService的bindProducer方法调用了doBindProducer
public <T> Binding<T> bindProducer(T output, String outputName) {
String bindingTarget = this.bindingServiceProperties
.getBindingDestination(outputName);
Binder<T, ?, ProducerProperties> binder = (Binder<T, ?, ProducerProperties>) getBinder(
outputName, output.getClass());
ProducerProperties producerProperties = this.bindingServiceProperties
.getProducerProperties(outputName);
if (binder instanceof ExtendedPropertiesBinder) {
Object extension = ((ExtendedPropertiesBinder) binder)
.getExtendedProducerProperties(outputName);
ExtendedProducerProperties extendedProducerProperties = new ExtendedProducerProperties<>(
extension);
BeanUtils.copyProperties(producerProperties, extendedProducerProperties);
producerProperties = extendedProducerProperties;
}
validate(producerProperties);
// 调用doBindProducer方法
Binding<T> binding = doBindProducer(output, bindingTarget, binder, producerProperties);
this.producerBindings.put(outputName, binding);
return binding;
}
继续追踪可以发现BinderAwareChannelResolver类的resolveDestination方法调用了bindProducer,该方法通过channelName从容器中获取发送消息的通道,如果不存在则根据通道名绑定的信息构建消息发送通道并关联上具体的消息中间件。resolveDestination方法返回的消息输出通道就可以直接用于发送消息。调用返回的MessageChannel的send方法,就可以完成消息的发送,也正是在这个send方法中抛出的Dispatcher has no subscribers
// 调用BinderAwareChannelResolver类的resolveDestination方法,获取MessageChannel对象并调用send方法发送消息
resolver.resolveDestination(channelName).send(MessageBuilder.createMessage(dataWrapper, messageHeaders), timeout);
public MessageChannel resolveDestination(String channelName) {
try {
// 更具通道名获取发送消息通道
return super.resolveDestination(channelName);
}
catch (DestinationResolutionException e) {
// intentionally empty; will check again while holding the monitor
}
// 如果发送消息通道不存在则创建。多线程可能会导致异常
synchronized (this) {
BindingServiceProperties bindingServiceProperties = this.bindingService.getBindingServiceProperties();
String[] dynamicDestinations = bindingServiceProperties.getDynamicDestinations();
boolean dynamicAllowed = ObjectUtils.isEmpty(dynamicDestinations) || ObjectUtils.containsElement(dynamicDestinations, channelName);
try {
return super.resolveDestination(channelName);
}
catch (DestinationResolutionException e) {
if (!dynamicAllowed) {
throw e;
}
}
MessageChannel channel = this.bindingTargetFactory.createOutput(channelName);
this.beanFactory.registerSingleton(channelName, channel);
this.instrumentChannelWithGlobalInterceptors(channel, channelName);
channel = (MessageChannel) this.beanFactory.initializeBean(channel, channelName);
if (this.newBindingCallback != null) {
ProducerProperties producerProperties = bindingServiceProperties.getProducerProperties(channelName);
Object extendedProducerProperties = this.bindingService.getExtendedProducerProperties(channel, channelName);
this.newBindingCallback.configure(channelName, channel, producerProperties, extendedProducerProperties);
bindingServiceProperties.updateProducerProperties(channelName, producerProperties);
}
Binding<MessageChannel> binding = this.bindingService.bindProducer(channel, channelName);
this.dynamicDestinationsBindable.addOutputBinding(channelName, binding);
return channel;
}
}
由上述代码分析可知,在resolveDestination方法进行MessageChannel初始化时,如果在doBindProducer方法调用((SubscribableChannel) outputChannel).subscribe(…)方法之前遇到异常将无法完成消息处理方法的注册,将会导致在之后send方法中获取不到消息的处理器导致抛出Dispatcher has no subscribers。那在resolveDestination方法中抛出的异常都将会是导致之后send方法抛出Dispatcher has no subscribers异常的原因
Failed to register bean with name ‘" + name + "’, since bean with the same name already exists…错误就是resolveDestination方法进行MessageChannel初始化时可能出现的异常。该异常的抛出点在AbstractMessageChannelBinder的registerComponentWithBeanFactory方法。该方法判断上下文中是否已经包含指定名称的bean,如果包含就会抛出上述异常
private void registerComponentWithBeanFactory(String name, Object component) {
if (getApplicationContext().getBeanFactory().containsBean(name)) {
throw new IllegalStateException("Failed to register bean with name '" + name + "', since bean with the same name already exists. Possible reason: "
+ "You may have multiple bindings with the same 'destination' and 'group' name (consumer side) "
+ "and multiple bindings with the same 'destination' name (producer side). Solution: ensure each binding uses different group name (consumer side) "
+ "or 'destination' name (producer side)." );
}
else {
getApplicationContext().getBeanFactory().registerSingleton(name, component);
}
}
查看registerComponentWithBeanFactory调用链可知AbstractMessageChannelBinder的registerErrorInfrastructure方法在进行调用,该方法在注册错误通道,错误通道的命名为destination.getName() + “.errors”,errorBridgeHandlerName的命名为destination.getName() + “.errors” + “.bridge”。在注错误通道或者errorBridge时都会调用registerComponentWithBeanFactory方法,传入错误通道名或errorBridgeHandlerName。由错误通道名、errorBridgeHandlerName的命名规则可知,如果两个不同通道对应同一个destination(对于Kafka就是topic),第一个通道完成初始化后第二个通道再初始化时,由于两个通道destination相同,第二个通道初始化时将会抛出上述异常。更近一步由于resolveDestination在初始化输出通道时并非线程安全,如果多个线程同时调用resolveDestination方法,第一个线程进入synchronized代码块,但还没有完成输出通道注册,之后的线程在上下文无法通过输出通道名获取bean,也会等待进入synchronized代码块的初始化输出通道逻辑。当第一个线程初始化输出通道逻辑结束,第二个线程进入synchronized代码块执行初始化输出通道逻辑,由于已经初始化完成,则在创建错误通道时会报上述异常,之后进入synchronized代码块的相同输出通道的线程都会报这个异常
private SubscribableChannel registerErrorInfrastructure(ProducerDestination destination) {
ConfigurableListableBeanFactory beanFactory = getApplicationContext().getBeanFactory();
// 获取错误通道名
String errorChannelName = errorsBaseName(destination);
SubscribableChannel errorChannel = null;
if (getApplicationContext().containsBean(errorChannelName)) {
Object errorChannelObject = getApplicationContext().getBean(errorChannelName);
if (!(errorChannelObject instanceof SubscribableChannel)) {
throw new IllegalStateException(
"Error channel '" + errorChannelName + "' must be a SubscribableChannel");
}
errorChannel = (SubscribableChannel) errorChannelObject;
}
else {
errorChannel = new PublishSubscribeChannel();
this.registerComponentWithBeanFactory(errorChannelName, errorChannel);
errorChannel = (PublishSubscribeChannel) beanFactory.initializeBean(errorChannel, errorChannelName);
}
MessageChannel defaultErrorChannel = null;
if (getApplicationContext().containsBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)) {
defaultErrorChannel = getApplicationContext().getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME,
MessageChannel.class);
}
if (defaultErrorChannel != null) {
BridgeHandler errorBridge = new BridgeHandler();
errorBridge.setOutputChannel(defaultErrorChannel);
errorChannel.subscribe(errorBridge);
// 获取errorBridgeHandlerName
String errorBridgeHandlerName = getErrorBridgeName(destination);
this.registerComponentWithBeanFactory(errorBridgeHandlerName, errorBridge);
beanFactory.initializeBean(errorBridge, errorBridgeHandlerName);
}
return errorChannel;
}
// 错误通道名生成规则
protected String errorsBaseName(ProducerDestination destination) {
return destination.getName() + ".errors";
}
// errorBridgeHandlerName生成规则
protected String getErrorBridgeName(ProducerDestination destination) {
return errorsBaseName(destination) + ".bridge";
}
"The number of expected partitions was: " + partitionCount + ", but " + partitionSize + (partitionSize > 1 ? " have " : " has ") + “been found instead.”…异常在KafkaTopicProvisioner类的createTopicAndPartitions方法中抛出。该方法判断如果传入的分区数大于实际分区数,并且没有设置自动增加分区数及isAutoRebalanceEnabled设置为false将抛出上述异常
private void createTopicAndPartitions(AdminClient adminClient, final String topicName, final int partitionCount,
boolean tolerateLowerPartitionsOnBroker, KafkaAdminProperties adminProperties) throws Throwable {
ListTopicsResult listTopicsResult = adminClient.listTopics();
KafkaFuture<Set<String>> namesFutures = listTopicsResult.names();
Set<String> names = namesFutures.get(operationTimeout, TimeUnit.SECONDS);
if (names.contains(topicName)) {
// only consider minPartitionCount for resizing if autoAddPartitions is true
// 有效的分区数
int effectivePartitionCount = this.configurationProperties.isAutoAddPartitions()
? Math.max(this.configurationProperties.getMinPartitionCount(), partitionCount)
: partitionCount;
DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(Collections.singletonList(topicName));
KafkaFuture<Map<String, TopicDescription>> topicDescriptionsFuture = describeTopicsResult.all();
Map<String, TopicDescription> topicDescriptions = topicDescriptionsFuture.get(operationTimeout, TimeUnit.SECONDS);
TopicDescription topicDescription = topicDescriptions.get(topicName);
// 实际分区数
int partitionSize = topicDescription.partitions().size();
// 实际分区数是否小于有效分区数
if (partitionSize < effectivePartitionCount) {
// 判断是否运行自动添加分区数
if (this.configurationProperties.isAutoAddPartitions()) {
CreatePartitionsResult partitions = adminClient.createPartitions(
Collections.singletonMap(topicName, NewPartitions.increaseTo(effectivePartitionCount)));
partitions.all().get(operationTimeout, TimeUnit.SECONDS);
}
// 判断是否允许更低的分区数
else if (tolerateLowerPartitionsOnBroker) {
logger.warn("The number of expected partitions was: " + partitionCount + ", but "
+ partitionSize + (partitionSize > 1 ? " have " : " has ") + "been found instead."
+ "There will be " + (effectivePartitionCount - partitionSize) + " idle consumers");
}
else {
throw new ProvisioningException("The number of expected partitions was: " + partitionCount + ", but "
+ partitionSize + (partitionSize > 1 ? " have " : " has ") + "been found instead."
+ "Consider either increasing the partition count of the topic or enabling " +
"`autoAddPartitions`");
}
}
}
else {
// always consider minPartitionCount for topic creation
final int effectivePartitionCount = Math.max(this.configurationProperties.getMinPartitionCount(),
partitionCount);
this.metadataRetryOperations.execute(context -> {
NewTopic newTopic;
Map<Integer, List<Integer>> replicasAssignments = adminProperties.getReplicasAssignments();
if (replicasAssignments != null && replicasAssignments.size() > 0) {
newTopic = new NewTopic(topicName, adminProperties.getReplicasAssignments());
}
else {
newTopic = new NewTopic(topicName, effectivePartitionCount,
adminProperties.getReplicationFactor() != null
? adminProperties.getReplicationFactor()
: configurationProperties.getReplicationFactor());
}
if (adminProperties.getConfiguration().size() > 0) {
newTopic.configs(adminProperties.getConfiguration());
}
CreateTopicsResult createTopicsResult = adminClient.createTopics(Collections.singletonList(newTopic));
try {
createTopicsResult.all().get(operationTimeout, TimeUnit.SECONDS);
}
catch (Exception e) {
if (e instanceof ExecutionException) {
String exceptionMessage = e.getMessage();
if (exceptionMessage.contains("org.apache.kafka.common.errors.TopicExistsException")) {
if (logger.isWarnEnabled()) {
logger.warn("Attempt to create topic: " + topicName + ". Topic already exists.");
}
}
else {
logger.error("Failed to create topics", e.getCause());
throw e.getCause();
}
}
else {
logger.error("Failed to create topics", e.getCause());
throw e.getCause();
}
}
return null;
});
}
}
在实际使用中,如果我们想要指定发送分区的策略,需要设置分区的大小,并且需要大于1。但如果我们设置分区的大小大于实际的大小,并且没有其它配置,有可能会报出上述错误.由于createTopicAndPartitions方法也是在resolveDestination初始化输出通道时执行,因此此异常抛出后会紧接着抛出Dispatcher has no subscribers for channel…异常
ProducerProperties producerProperties = new ProducerProperties();
producerProperties.setPartitionKeyExpression(new SpelExpressionParser().parseExpression("payload.tenantId"));
producerProperties.setPartitionCount(2);
eventSender.fireEvent(EventSenderConfig.newBuilder()
.tenantId(0L)
.eventCode("HALT_TARGET_1")
.category("HALT_TARGET_1")
.producerProperties(producerProperties)
.data(alertRoute)
.builder()
通过上面原因的分析以及结合具体报错分析可知,Dispatcher has no subscribers for channel…异常只是结果,真正触发抛出此异常的原因需要看resolveDestination初始化时抛出的异常,此异常通常在Dispatcher has no subscribers for channel…异常的前面抛出,并且基本都挨在一起。因此遇到Dispatcher has no subscribers for channel…异常可以往前翻翻,找到具体报错原因,具体问题具体分析
在调用EventSender方法的fireEvent方法发送消息时,如果两个不同eventCode的两个事件,它们都指定了topic,并且topic还相同,在同一个服务下,当第一个事件先发送消息,第二个事件后发送消息,第二个发送消息的事件将报错
AlertRoute alertRoute = new AlertRoute();
alertRoute.setAlertRouteId(1L);
eventSender.fireEvent(EventSenderConfig.newBuilder()
.tenantId(0L)
.eventCode("HALT_TARGET_1")
.category("HALT_TARGET_1")
.data(alertRoute)
.builder()
, message -> {
System.out.println("======message=====Headers " + message.getHeaders() + "================");
System.out.println("======message=====Payload " + message.getPayload() + "================");
});
eventSender.fireEvent(CustomTopicSenderConfig.newBuilder()
.topic("halt-target-test-13")
.channelName("halt-target-test-11010")
.data(alertRoute)
.eventSourceCode("hzero-kafaka")
.tenantId(0L)
.builder()
, message -> {
System.out.println("======message=====Headers " + message.getHeaders() + "================");
System.out.println("======message=====Payload " + message.getPayload() + "================");
});
每个topic最好只对应一个事件,如果非要对应多个事件,那同一个服务中,不能使用两个不同事件但topic相同
当服务启动时开启异步线程发送消息,此时事件客户端启动完成初始化的阶段不能确定,有可能事件客户端还没开始初始化,或者初始化正在进行,此时异步线程发送消息可能导致不能预料的错误,具体错误与事件客户端进行进度有关
监听事件客户端启动完成后发布的EventSender事件,在监听EventSender的回调方法中执行异步发送消息的逻辑。事件监听的相关知识请查看https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#spring-core
多线程并发调用发送消息方法,并且都是往同一个事件发送消息,可能导致第一个线程进入resolveDestination方法的synchronized代码块,但还没有完成输出通道注册,之后的线程在上下文无法通过输出通道名获取bean,也会等待进入synchronized代码块的初始化输出通道逻辑。当第一个线程初始化输出通道逻辑结束,第二个线程进入synchronized代码块执行初始化输出通道逻辑,由于已经初始化完成,则在创建错误通道时会报上述异常,之后进入synchronized代码块的相同输出通道的线程都会报这个异常
ProducerProperties producerProperties = new ProducerProperties();
producerProperties.setPartitionKeyExpression(new SpelExpressionParser().parseExpression("payload.tenantId"));
producerProperties.setPartitionCount(2);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
for(int i=0; i< 10 ; i++) {
eventSender.fireEvent(EventSenderConfig.newBuilder()
.tenantId(0L)
.eventCode("HALT_TARGET_1")
.category("HALT_TARGET_1")
.producerProperties(producerProperties)
.data(alertRoute)
.builder()
, message -> {
System.out.println("======message=====Headers " + message.getHeaders() + "================");
System.out.println("======message=====Payload " + message.getPayload() + "================");
});
}
}
});
thread.start();
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
for(int i=0; i< 10 ; i++) {
eventSender.fireEvent(EventSenderConfig.newBuilder()
.tenantId(0L)
.eventCode("HALT_TARGET_1")
.category("HALT_TARGET_1")
.producerProperties(producerProperties)
.data(alertRoute)
.builder()
, message -> {
System.out.println("======message=====Headers " + message.getHeaders() + "================");
System.out.println("======message=====Payload " + message.getPayload() + "================");
});
}
}
});
thread2.start();
覆盖BinderAwareChannelResolver,重写resolveDestination方法,在进入synchronized方法块后再尝试从上下文获取通道名对应的bean,如果获取到,则表明上个线程已经创建好输出通道,直接返回使用;如果还不能获取到输出通道的bean,则继续执行初始化任务
public MessageChannel resolveDestination(String channelName) {
try {
return super.resolveDestination(channelName);
} catch (DestinationResolutionException var12) {
synchronized(this) {
// 如果再次获取输出通道成功则直接返回,失败则继续执行下面逻辑
try{
return super.resolveDestination(channelName)
} catch (DestinationResolutionException var12) {
}
BindingServiceProperties bindingServiceProperties = this.bindingService.getBindingServiceProperties();
String[] dynamicDestinations = bindingServiceProperties.getDynamicDestinations();
boolean dynamicAllowed = ObjectUtils.isEmpty(dynamicDestinations) || ObjectUtils.containsElement(dynamicDestinations, channelName);
MessageChannel var10000;
try {
var10000 = super.resolveDestination(channelName);
} catch (DestinationResolutionException var10) {
if (!dynamicAllowed) {
throw var10;
}
MessageChannel channel = (MessageChannel)this.bindingTargetFactory.createOutput(channelName);
this.beanFactory.registerSingleton(channelName, channel);
this.instrumentChannelWithGlobalInterceptors(channel, channelName);
channel = (MessageChannel)this.beanFactory.initializeBean(channel, channelName);
if (this.newBindingCallback != null) {
ProducerProperties producerProperties = bindingServiceProperties.getProducerProperties(channelName);
Object extendedProducerProperties = this.bindingService.getExtendedProducerProperties(channel, channelName);
this.newBindingCallback.configure(channelName, channel, producerProperties, extendedProducerProperties);
bindingServiceProperties.updateProducerProperties(channelName, producerProperties);
}
Binding<MessageChannel> binding = this.bindingService.bindProducer(channel, channelName);
this.dynamicDestinationsBindable.addOutputBinding(channelName, binding);
return channel;
}
return var10000;
}
}
}
文章浏览阅读1.1k次。一、选择题1. 串行接口是指( )。A. 接口与系统总线之间串行传送,接口与I/0设备之间串行传送B. 接口与系统总线之间串行传送,接口与1/0设备之间并行传送C. 接口与系统总线之间并行传送,接口与I/0设备之间串行传送D. 接口与系统总线之间并行传送,接口与I/0设备之间并行传送【答案】C2. 最容易造成很多小碎片的可变分区分配算法是( )。A. 首次适应算法B. 最佳适应算法..._874 计算机科学专业基础综合题型
文章浏览阅读9.7k次,点赞5次,收藏15次。连接xshell失败,报错如下图,怎么解决呢。1、通过ps -e|grep ssh命令判断是否安装ssh服务2、如果只有客户端安装了,服务器没有安装,则需要安装ssh服务器,命令:apt-get install openssh-server3、安装成功之后,启动ssh服务,命令:/etc/init.d/ssh start4、通过ps -e|grep ssh命令再次判断是否正确启动..._could not connect to '192.168.17.128' (port 22): connection failed.
文章浏览阅读209次。00000000_杰理 空白芯片 烧入key文件
文章浏览阅读475次。2023年初,“ChatGPT”一词在社交媒体上引起了热议,人们纷纷探讨它的本质和对社会的影响。就连央视新闻也对此进行了报道。作为新传专业的前沿人士,我们当然不能忽视这一热点。本文将全面解析ChatGPT,打开“技术黑箱”,探讨它对新闻与传播领域的影响。_引发对chatgpt兴趣的表述
文章浏览阅读259次。用Python数据分析方法进行汉字声调频率统计分析木合塔尔·沙地克;布合力齐姑丽·瓦斯力【期刊名称】《电脑知识与技术》【年(卷),期】2017(013)035【摘要】该文首先用Python程序,自动获取基本汉字字符集中的所有汉字,然后用汉字拼音转换工具pypinyin把所有汉字转换成拼音,最后根据所有汉字的拼音声调,统计并可视化拼音声调的占比.【总页数】2页(13-14)【关键词】数据分析;数据可..._汉字声调频率统计
文章浏览阅读64次。最近在做一个android系统移植的项目,所使用的开发板com1是调试串口,就是说会有uboot和kernel的调试信息打印在com1上(ttySAC0)。因为后期要使用ttySAC0作为上层应用通信串口,所以要把所有的调试信息都给去掉。参考网上的几篇文章,自己做了如下修改,终于把调试信息重定向到ttySAC1上了,在这做下记录。参考文章有:http://blog.csdn.net/longt..._嵌入式rootfs 输出重定向到/dev/console
文章浏览阅读1.2k次,点赞4次,收藏12次。1,先去iconfont登录,然后选择图标加入购物车 2,点击又上角车车添加进入项目我的项目中就会出现选择的图标 3,点击下载至本地,然后解压文件夹,然后切换到uniapp打开终端运行注:要保证自己电脑有安装node(没有安装node可以去官网下载Node.js 中文网)npm i -g iconfont-tools(mac用户失败的话在前面加个sudo,password就是自己的开机密码吧)4,终端切换到上面解压的文件夹里面,运行iconfont-tools 这些可以默认也可以自己命名(我是自己命名的_uniapp symbol图标
文章浏览阅读1.2w次,点赞25次,收藏192次。char*和char[]都是指针,指向第一个字符所在的地址,但char*是常量的指针,char[]是指针的常量_c++ char*
文章浏览阅读930次。代码编辑器或者文本编辑器,对于程序员来说,就像剑与战士一样,谁都想拥有一把可以随心驾驭且锋利无比的宝剑,而每一位程序员,同样会去追求最适合自己的强大、灵活的编辑器,相信你和我一样,都不会例外。我用过的编辑器不少,真不少~ 但却没有哪款让我特别心仪的,直到我遇到了 Sublime Text 2 !如果说“神器”是我能给予一款软件最高的评价,那么我很乐意为它封上这么一个称号。它小巧绿色且速度非
文章浏览阅读4.1k次。一、选择法这是每一个数出来跟后面所有的进行比较。2.冒泡排序法,是两个相邻的进行对比。_对十个数进行大小排序java
文章浏览阅读2.9k次。物联网开发笔记——使用网络调试助手连接阿里云物联网平台(基于MQTT协议)其实作者本意是使用4G模块来实现与阿里云物联网平台的连接过程,但是由于自己用的4G模块自身的限制,使得阿里云连接总是无法建立,已经联系客服返厂检修了,于是我在此使用网络调试助手来演示如何与阿里云物联网平台建立连接。一.准备工作1.MQTT协议说明文档(3.1.1版本)2.网络调试助手(可使用域名与服务器建立连接)PS:与阿里云建立连解释,最好使用域名来完成连接过程,而不是使用IP号。这里我跟阿里云的售后工程师咨询过,表示对应_网络调试助手连接阿里云连不上
文章浏览阅读544次,点赞5次,收藏6次。运算符与表达式任何高级程序设计语言中,表达式都是最基本的组成部分,可以说C++中的大部分语句都是由表达式构成的。_无c语言基础c++期末速成