PubSubInboundChannelAdapter stops to receive messages after 4th message

前端 未结 1 1301
猫巷女王i
猫巷女王i 2021-01-25 18:44

I\'ve created simplified example which reproduces my real problem.

My example accepts from google pub/sub, logs it and send ack back to the Pub/Sub

1条回答
  •  盖世英雄少女心
    2021-01-25 19:35

    You problem is here:

    .gateway(acknowledgementFlow);
    

    It means request-reply and we can't guess that your acknowledgementFlow is one-way flow. I see that by your MyPubSubAckHandler implementation which returns void for its handleMessage() implementation. This way a gateway waits for reply, but the real sub-flow will never return any result. Therefore awaiting for reply threads are stuck and eventually your application fail.

    One of the solution is to make a GatewayEndpointSpec.replyTimeout() as 0. So, your void sub-flow won't block a main flow for potential reply.

    Another way just don't use gateway(), but that sub-flow content directly in the main flow. It really doesn't look like you expect some reply so this should work for you:

      return flow -> flow.channel(bucketNotificationChannel())
                .handle(handler)
                .log(INFO, "Handler finished", m -> {
                    return "got" + m;
                })
                .log(DEBUG, "acknowledgementFlow", m -> "Handling acknowledgement for message: " + m)
                .handle(pubSubAckHandler);
    

    0 讨论(0)
提交回复
热议问题