事件通道

Alpha 收到 Omeag 发送的事件后放入事件通道等待 Akka 处理,事件通道有三种实现方式,一种是内存通道另外是 Kafka,Rabbit 通道

通道类型模式说明
memory单例使用内存作为数据通道,不建议在生产环境使用
kafka集群使用 Kafka 作为数据通道,使用全局事务ID作为分区策略,集群中的所有节点同时工作,可水平扩展,当配置了 spring.profiles.active=prd,cluster 参数后默认就使用 kafka 通道
rabbit集群使用 rabbit 作为数据通道,使用全局事务ID作为分区策略, 由于rabbit 原生不支持分区,所以引用了 spring-cloud-stream

可以使用参数 alpha.feature.akka.channel.type 配置通道类型

  • Memory 通道参数
参数名参数值说明
alpha.feature.akka.channel.typememory
alpha.feature.akka.channel.memory.size-1momory类型时内存队列大小,-1表示Integer.MAX
  • Kafka 通道参数
参数名参数值说明
alpha.feature.akka.channel.typekafka
spring.kafka.bootstrap-servers-1momory类型时内存队列大小,-1表示Integer.MAX
spring.kafka.producer.batch-size16384
spring.kafka.producer.retries0
spring.kafka.producer.buffer.memory33554432
spring.kafka.consumer.auto.offset.resetearliest
spring.kafka.listener.pollTimeout1500
kafka.numPartitions6
kafka.replicationFactor1
  • Rabbit 通道参数
参数名参数值说明
alpha.feature.akka.channel.typerabbit
spring.cloud.stream.instance-index0分区索引
spring.cloud.stream.instance-count1
spring.cloud.stream.bindings.service-comb-pack-producer.producer.partition-count1分区数量,分区数量需要与alpha-server保持一致
spring.cloud.stream.binders.defaultRabbit.environment.spring.rabbitmq.virtual-hostservicecomb-pack
spring.cloud.stream.binders.defaultRabbit.environment.spring.rabbitmq.hostrabbitmq.servicecomb.io
spring.cloud.stream.binders.defaultRabbit.environment.spring.rabbitmq.usernameservicecomb-pack
spring.cloud.stream.binders.defaultRabbit.environment.spring.rabbitmq.passwordH123213PWD
spring.cloud.stream.binders.defaultRabbit.typerabbit
spring.cloud.stream.bindings.service-comb-pack-producer.destinationexchange-service-comb-pack
spring.cloud.stream.bindings.service-comb-pack-producer.content-typeapplication/json
spring.cloud.stream.bindings.service-comb-pack-producer.producer.partition-key-expressionheaders[‘partitionKey’]分区表达式
spring.cloud.stream.bindings.service-comb-pack-consumer.groupgroup-pack
spring.cloud.stream.bindings.service-comb-pack-consumer.content-typeapplication/json
spring.cloud.stream.bindings.service-comb-pack-consumer.destinationexchange-service-comb-pack
spring.cloud.stream.bindings.service-comb-pack-consumer.consumer.partitionedtrue