@@ -1401,6 +1401,11 @@ public void testNonBlockingWithMultipleMessages() throws Exception {
14011401
14021402 assertTrue (subscriptionLatch .await (15 , TimeUnit .SECONDS ));
14031403
1404+ // CRITICAL: Wait for subscribeToTask's child queue poller to start
1405+ // This ensures it's ready to receive events from the upcoming sendMessage
1406+ assertTrue (awaitChildQueueCountStable (taskId , 1 , 5000 ),
1407+ "subscribeToTask child queue should be created and stable" );
1408+
14041409 // 3. Send second streaming message to same taskId
14051410 Message message2 = Message .builder (MESSAGE )
14061411 .taskId (multiEventTaskId ) // Same taskId
@@ -1492,6 +1497,23 @@ public void testNonBlockingWithMultipleMessages() throws Exception {
14921497 }
14931498 }
14941499
1500+ private boolean awaitChildQueueCountStable (String taskId , int expectedCount , long timeoutMs ) throws IOException , InterruptedException {
1501+ HttpClient client = HttpClient .newBuilder ()
1502+ .version (HttpClient .Version .HTTP_2 )
1503+ .build ();
1504+ HttpRequest request = HttpRequest .newBuilder ()
1505+ .uri (URI .create ("http://localhost:" + serverPort + "/test/queue/awaitChildCountStable/" +
1506+ taskId + "/" + expectedCount + "/" + timeoutMs ))
1507+ .POST (HttpRequest .BodyPublishers .noBody ())
1508+ .build ();
1509+
1510+ HttpResponse <String > response = client .send (request , HttpResponse .BodyHandlers .ofString (StandardCharsets .UTF_8 ));
1511+ if (response .statusCode () != 200 ) {
1512+ throw new RuntimeException (response .statusCode () + ": Awaiting child queue count failed! " + response .body ());
1513+ }
1514+ return Boolean .parseBoolean (response .body ());
1515+ }
1516+
14951517 @ Test
14961518 @ Timeout (value = 1 , unit = TimeUnit .MINUTES )
14971519 public void testInputRequiredWorkflow () throws Exception {
0 commit comments