问题描述
我正在尝试配置同时使用Hystrix断路器和交货重试的路由。断路器可以正常工作并跳闸,但是当断路器的后备功能触发拒绝后续呼叫时,重试不会发生。
以下是带有断路器和重试策略的路由配置:
// Route: DES Evaluation Engine -> DES Service Bus -> VSA and KMS Data Collectors
from("activemq:" + amqBrokerConfig.getDesDataCollectionRequestsOutQueue() + jmsFromEndpointOptions)
.onException(Exception.class)
.retryWhile(deliveryRetryRuleset)
.maximumRedeliveries(serviceBusConfig.getDesMaxRedeliveries())
.maximumRedeliveryDelay(serviceBusConfig.getDesMaxRedeliveryDelayMs())
.redeliveryDelay(serviceBusConfig.getDesInitialRedeliveryDelayMs())
.end()
.log("Relaying messages to Luma/VSA & Luma/KMS endpoints:: Sending ${body} with correlation key ${header.CorrelationId}")
// Splits the message to be sent to different end points
.split().method(ServiceCommandSplitter.class,"splitCommands")
// Use the assembler to aggregate facts received from each individual endpoints i.e. Luma/VSA & Luma/KMS
.aggregationStrategy(new FactsAssembler())
// Sets a total timeout to breakout from multicast if replies aren't received within the stipulated time
.timeout(serviceBusConfig.getDesMulticastProcessingTimeoutMs())
// Sending of message to the multiple endpoints must occur concurrently
.parallelProcessing()
.log("Splitted message: ${body}")
// Encapsulate operation within a circuit breaker and monitor it for failures
.circuitBreaker().hystrixConfiguration(hystrixConfig)
// Identify the end point
.choice()
// Forward the message to Luma/VSA Data Collector
.when(jsonpath("$.commandName").isEqualTo(CommandName.GET_INTENT_REPRESENTATION.getName()))
.to("activemq:" + amqBrokerConfig.getVsaDataCollectionRequestsInQueue() + toOptions)
// Forward the message to Luma/KMS Data Collector
.when(jsonpath("$.commandName").isEqualTo(CommandName.SEARCH_KNOWLEDGE_BASE.getName()))
.to("activemq:" + amqBrokerConfig.getKmsDataCollectionRequestsInQueue() + toOptions)
.endCircuitBreaker()
// The fallback route path to execute that does not go over the network.
.onFallback()
// Add the custom processor
.process(new DataCollectionFallbackProcessor())
// Mark end of current block and returns back to the circuitBreaker()
.end();
有人可以建议我可能丢失的内容,以便在发生异常时触发重试吗?
以下是用于确认断路器功能被触发的日志跟踪。
29-Sep-2020 06:49:57,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 225 | | o.a.c.c.j.JmsConfiguration | Sending JMS message to: queue://MQ.VSADataCollectionRequests.in with message: ActiveMQTextMessage {commandId = 0,responseRequired = false,messageId = null,originalDestination = null,originalTransactionId = null,producerId = null,destination = null,transactionId = null,expiration = 1601362198609,timestamp = 0,arrival = 0,brokerInTime = 0,brokerOutTime = 0,correlationId = Camel-ID-Darpan-Laptop-1601362137830-0-60,replyTo = temp-queue://ID:Darpan-Laptop-55243-1601362137447-13:1:1,persistent = true,type = null,priority = 4,groupID = null,groupSequence = 0,targetConsumerId = null,compressed = false,userID = null,content = null,marshalledProperties = null,dataStructure = null,redeliveryCounter = 0,size = 0,properties = {TenantExternalId=48939482-840a-4c0a-8df1-437c27208eff,ContactId=-1},readOnlyProperties = false,readOnlyBody = false,droppable = false,jmsXGroupFirstForConsumer = false,text = {"serviceId":"DESserviceBus","requestId":"Dar...ctId":-1}}}}}
29-Sep-2020 06:49:57,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 224 | | o.a.c.c.j.JmsConfiguration | Sending JMS message to: queue://MQ.KMSDataCollectionRequests.in with message: ActiveMQTextMessage {commandId = 0,correlationId = Camel-ID-Darpan-Laptop-1601362137830-0-61,replyTo = temp-queue://ID:Darpan-Laptop-55243-1601362137447-14:1:1,properties = {TenantExternalId=51a014bd-cb6c-44d1-b44f-43ea87d9d2ac,"requestId":"Dar...ctId":-1}}}}}
29-Sep-2020 06:50:00,615 | WARN | DESserviceBus | Darpan-Laptop | | | 231 | | c.s.d.e.c.FactsAssembler | Parallel processing timed out after 3000 millis for number 0. This task will be cancelled and will not be aggregated.
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 223 | | o.a.c.c.h.p.HystrixProcessorCommand | Error occurred processing. Will now run fallback. Exception class: com.netflix.hystrix.exception.HystrixTimeoutException message: null.
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 223 | | o.a.c.c.h.p.HystrixProcessorCommand | Running fallback: Channel[DelegateSync[com.sa.des.esb.components.DataCollectionFallbackProcessor@7ed8b44]] with exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-59]
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 222 | | o.a.c.c.h.p.HystrixProcessorCommand | Error occurred processing. Will now run fallback. Exception class: com.netflix.hystrix.exception.HystrixTimeoutException message: null.
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 225 | | o.a.c.c.h.p.HystrixProcessorCommand | Exiting run command due to a hystrix execution timeout in processing exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-58]
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 224 | | o.a.c.c.h.p.HystrixProcessorCommand | Exiting run command due to a hystrix execution timeout in processing exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-59]
29-Sep-2020 06:50:00,615 | WARN | DESserviceBus | Darpan-Laptop | | | 231 | | c.s.d.e.c.FactsAssembler | Parallel processing timed out after 3000 millis for number 1. This task will be cancelled and will not be aggregated.
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 222 | | o.a.c.c.h.p.HystrixProcessorCommand | Running fallback: Channel[DelegateSync[com.sa.des.esb.components.DataCollectionFallbackProcessor@7ed8b44]] with exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-58]
29-Sep-2020 06:50:00,616 | DEBUG | DESserviceBus | Darpan-Laptop | | | 231 | | c.s.d.e.c.FactsAssembler | Assembling and aggregating all the facts collected using aggregated exchange:
29-Sep-2020 06:50:00,616 | DEBUG | DESserviceBus | Darpan-Laptop | | | 222 | | c.s.d.e.c.DataCollectionFallbackProcessor | Executing fallback processing for data collection message routing.
29-Sep-2020 06:50:00,615 | DEBUG | DESserviceBus | Darpan-Laptop | | | 223 | | c.s.d.e.c.DataCollectionFallbackProcessor | Executing fallback processing for data collection message routing.
29-Sep-2020 06:50:00,616 | DEBUG | DESserviceBus | Darpan-Laptop | | | 222 | | o.a.c.c.h.p.HystrixProcessorCommand | Running fallback: Channel[DelegateSync[com.sa.des.esb.components.DataCollectionFallbackProcessor@7ed8b44]] with exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-58] done
29-Sep-2020 06:50:00,616 | DEBUG | DESserviceBus | Darpan-Laptop | | | 223 | | o.a.c.c.h.p.HystrixProcessorCommand | Running fallback: Channel[DelegateSync[com.sa.des.esb.components.DataCollectionFallbackProcessor@7ed8b44]] with exchange: Exchange[ID-Darpan-Laptop-1601362137830-0-59] done
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)