1.概述
connector承担的职责 是 zeebe的task跟外部系统通信,其中inboundConnector则是监听外部系统的信息,目前git社区已经支持其中包括 kafka 、rabbitMQ、rest-http、sqs、slack等。
在代码实现层面,每一个 inboundConnector 就是一个listener,监听外部系统的变化,进而触发zeebe的相关任务
2. inboundConnector发现、注册
inboundConnector一共有三种加载方式:
1.通过spi加载
2.通过配置文件指定(会覆盖 @IutboundConnector 中指定的属性)
3.通过spring 的beanProcessor扫描注解 @IutboundConnector
具体的跟outboundConnector的处理是类似的,此处只列举关键方法:
通过spi、注解发现的关键方法:
io.camunda.connector.runtime.core.inbound.DefaultInboundConnectorFactory#loadConnectorConfigurations
通过spring 的beanProcessor扫描注解 @IutboundConnector 关键处理类: InboundConnectorAnnotationProcessor
io.camunda.connector.runtime.inbound.lifecycle.InboundConnectorAnnotationProcessor#registerInboundConnector
3.实例化 inboundConnector
由定时任务触发: io.camunda.connector.runtime.inbound.importer.ProcessDefinitionImporter#scheduleImport
io.camunda.connector.runtime.inbound.importer.ProcessDefinitionImporter#handleImportedDefinitions
io.camunda.connector.runtime.inbound.lifecycle.InboundConnectorManager#handleNewProcessDefinitions
3.1 connector的激活
关键方法,激活 inboundConnector
io.camunda.connector.runtime.inbound.lifecycle.InboundConnectorManager#activateConnector
对于激活connector,以 HttpPollingConnector 为示例说明:
如图,其委托给了 ProcessInstancesFetcherTask 处理具体逻辑。
最后具体的执行逻辑在 子线程的run()方法中:
io.camunda.connector.http.polling.task.ProcessInstancesFetcherTask#run
发起http请求之后,其response会通过 发送事件 的方式回写至zeebe broker
io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler#correlate
io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler#triggerMessage