这里我有一个 spring 集成流程,当多个并行调用进入这个流程时,我收到错误提示 -
Reply message received but the receiving thread has already received a reply: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [bean 'myFlow.aggregator#1'; defined in: 'class path resource
[com/example/config/SpringIntegrationConfiguration.class]'; from source: 'bean method myFlow']; nested exception is java.lang.IllegalStateException: 'upperBound' must not be null., failedMessage=GenericMessage
[payload=<200,[x-content-type-options:"nosniff", x-xss-protection:"1; mode=block", cache-control:"no-cache, no-store, max-age=0, must-revalidate", pragma:"no-cache", expires:"0", x-frame-options:"DENY", content-length:"0", date:"Wed, 05 Apr 2023 20:26:14 GMT",
x-envoy-upstream-service-time:"28", server:"envoy"]>, headers={date=1680726374000, dataIndicator=false, content-length=0, server=envoy, sequenceDetails=[[88568fbe-093f-eb0c-5641-5ad0f8146727, 1, 1], [2a761702-6de6-7d1e-70be-8de17cb0dfb8, 1, 5],
[47817b6b-6001-aeb0-ad33-3d381a78bea4, 1, 1]], gatherResultChannel=org.springframework.integration.channel.QueueChannel@47a1bb33,SystemCd=01, transfer-encoding=chunked,
errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@18bd0ff1, vary=accept-encoding, originalErrorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@18bd0ff1, sequenceSize=2, http_statusCode=200 OK,
createdAt=2023-04-05 20:26:14.481, requestNumber=4915032, correlationId=efda3694-5da2-c51a-c3a5-b9d92999f42a, id=87fd4dd6-90a9-ef73-49da-c3be149a9792, cache-control=no-cache, no-store, max-age=0, must-revalidate, contentType=application/json, timestamp=1680726374805,
sequenceNumber=2,rQty=0, product-type=Personal, pragma=no-cache, endPoint=STRATEGIC, replyChannel=org.springframework.integration.channel.FixedSubscriberChannel@9fb399f, dbID=867542,
user-id=TestAutomation, dataFlag=true}], headers={id=98d42441-a4a4-45a1-0686-5581459dbed9, timestamp=1680726374805}]
这个问题不会出现在正常通话中,但是如果有很多并行点击,那么这个问题就会出现。
这是我的 Spring 集成配置 -
@Bean
public IntegrationFlow myFlow() {
return flow ->
flow.handle(validatorService, "validateRequest")
.channel(c -> c.executor(Executors.newCachedThreadPool()))
.log("Parallel Processing started")
.scatterGather(
scatterer ->
scatterer
.applySequence(true)
.recipientFlow(savingRequestToTheDB())
.recipientFlow(flow1())
.recipientFlow(flow2())
.recipientFlow(conditionToCallFlow3, flow3())
.recipientFlow(
conditionToCallFlow4,
flow4()),
gatherer -> gatherer.outputProcessor(gatherAndProcess()))
.log("Parallel Processing ended")
.gateway(getSomethng(), f -> f.errorChannel("cdErrorChannel"))
.handle(lionService, "setIndicator")
.split()
.channel(c -> c.executor(Executors.newCachedThreadPool()))
.scatterGather(
scatterer ->
scatterer
.applySequence(true)
.recipientFlow(prepareResponse())
.recipientFlow(conditionToCallFlow5, flow5()),
gatherer ->
gatherer.outputProcessor(savingLionResponse()));
}