技术标签: 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;
}
}
}
文章浏览阅读3.3k次,点赞7次,收藏39次。CPU 执行现行程序的过程中,出现某些急需处理的异常情况或特殊请求,CPU暂时中止现行程序,而转去对异常情况或特殊请求进行处理,处理完毕后再返回现行程序断点处,继续执行原程序。void 函数名(void) interrupt n using m {中断函数内容 //尽量精简 }编译器会把该函数转化为中断函数,表示中断源编号为n,中断源对应一个中断入口地址,而中断入口地址的内容为跳转指令,转入本函数。using m用于指定本函数内部使用的工作寄存器组,m取值为0~3。该修饰符可省略,由编译器自动分配。_51单片机中断篇
文章浏览阅读396次。项目经验(案例一)项目时间:2009-10 - 2009-12项目名称:中驰别克信息化管理整改完善项目描述:项目介绍一,建立中驰别克硬件档案(PC,服务器,网络设备,办公设备等)二,建立中驰别克软件档案(每台PC安装的软件,财务,HR,OA,专用系统等)三,能过建立的档案对中驰别克信息化办公环境优化(合理使用ADSL宽带资源,对域进行调整,对文件服务器进行优化,对共享打印机进行调整)四,优化完成后..._网络工程师项目经历
文章浏览阅读1k次,点赞31次,收藏30次。LVS:Linux Virtual Server,负载调度器,内核集成, 阿里的四层SLB(Server Load Balance)是基于LVS+keepalived实现。NATTUNDR优点端口转换WAN性能最好缺点性能瓶颈服务器支持隧道模式不支持跨网段真实服务器要求anyTunneling支持网络private(私网)LAN/WAN(私网/公网)LAN(私网)真实服务器数量High (100)High (100)真实服务器网关lvs内网地址。
文章浏览阅读899次。https://www.toutiao.com/a6713171323893318151/作者 | 黄小邪/言有三编辑 | 黄小邪/言有三图像预处理算法的好坏直接关系到后续图像处理的效果,如图像分割、目标识别、边缘提取等,为了获取高质量的数字图像,很多时候都需要对图像进行降噪处理,尽可能的保持原始信息完整性(即主要特征)的同时,又能够去除信号中无用的信息。并且,降噪还引出了一..._噪声很大的图片可以降噪吗
文章浏览阅读152次。目录谨慎地覆盖cloneCloneable接口并没有包含任何方法,那么它到底有什么作用呢?Object类中的clone()方法如何重写好一个clone()方法1.对于数组类型我可以采用clone()方法的递归2.如果对象是非数组,建议提供拷贝构造器(copy constructor)或者拷贝工厂(copy factory)3.如果为线程安全的类重写clone()方法4.如果为需要被继承的类重写clone()方法总结谨慎地覆盖cloneCloneable接口地目的是作为对象的一个mixin接口(详见第20_为继承设计类有两种选择,但无论选择其中的
文章浏览阅读958次,点赞21次,收藏24次。今天学长向大家分享一个毕业设计项目基于协同过滤的电影推荐系统项目运行效果:项目获取:https://gitee.com/assistant-a/project-sharing21世纪是信息化时代,随着信息技术和网络技术的发展,信息化已经渗透到人们日常生活的各个方面,人们可以随时随地浏览到海量信息,但是这些大量信息千差万别,需要费事费力的筛选、甄别自己喜欢或者感兴趣的数据。对网络电影服务来说,需要用到优秀的协同过滤推荐功能去辅助整个系统。系统基于Python技术,使用UML建模,采用Django框架组合进行设
文章浏览阅读614次。10G SFP+光模块被广泛应用于10G以太网中,在下一代移动网络、固定接入网、城域网、以及数据中心等领域非常常见。下面易天光通信(ETU-LINK)就为大家一一盘点下10G SFP+光模块都有哪些吧。一、10G SFP+双纤光模块10G SFP+双纤光模块是一种常规的光模块,有两个LC光纤接口,传输距离最远可达100公里,常用的10G SFP+双纤光模块有10G SFP+ SR、10G SFP+ LR,其中10G SFP+ SR的传输距离为300米,10G SFP+ LR的传输距离为10公里。_10g sfp+
文章浏览阅读239次。该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程。欢迎交流项目运行环境配置:项目技术:Express框架 + Node.js+ Vue 等等组成,B/S模式 +Vscode管理+前后端分离等等。环境需要1.运行环境:最好是Nodejs最新版,我们在这个版本上开发的。其他版本理论上也可以。2.开发环境:Vscode或HbuilderX都可以。推荐HbuilderX;3.mysql环境:建议是用5.7版本均可4.硬件环境:windows 7/8/10 1G内存以上;_基于vue美食网站源码
文章浏览阅读62次。oldwain随便写@hexun链接:http://oldwain.blog.hexun.com/ ...
文章浏览阅读843次,点赞16次,收藏22次。用这个工具扫描其它网站时,要注意法律问题,同时也比较慢,所以我们以之前写的登录页面为例子扫描。_sqlmap拖库
文章浏览阅读1.5w次,点赞5次,收藏38次。Origin也能玩转图片的拼接组合排版谭编(华南师范大学学报编辑部,广州 510631)通常,我们利用Origin软件能非常快捷地绘制出一张单独的绘图。但是,我们在论文的撰写过程中,经常需要将多种科学实验图片(电镜图、示意图、曲线图等)组合在一张图片中。大多数人都是采用PPT、Adobe Illustrator、CorelDraw等软件对多种不同类型的图进行拼接的。那么,利用Origin软件能否实..._origin怎么把三个图做到一张图上
文章浏览阅读4.2k次,点赞4次,收藏51次。51单片机智能电风扇控制系统仿真设计( proteus仿真+程序+原理图+报告+讲解视频)仿真图proteus7.8及以上 程序编译器:keil 4/keil 5 编程语言:C语言 设计编号:S0042。_电风扇模拟控制系统设计