AndThen seems to be firing out of order on JMS messages

It seems my scenarios are not abiding by the order I would expect.
Top level scenario is this

setUp(TestEnvironment.initializeForTest()
    .andThen(scenario1("PostOrderJMSMessages-1").injectOpen(atOnceUsers(1)))
    .andThen(TestEnvironment.checkJmsPerformanceStats())
)
.assertions(...)

I want to use a scenario for test initialization so I can use Gatling plumbing and bail if the environment is not ready

So the first call is to this fn()

public static PopulationBuilder initializeForTest() {
      return scenario("Setup")
         .exec(s -> {
            LOGGER.info("Setting up test environment");
            return s;
         })
         .exec(validateJMSConnections())
         .pause(Duration.ofMillis(200))
         .exec(resetActiveMQCounters())
         .pause(Duration.ofMillis(200))
         .exec(validateJMSCounterReset())
         .exitHereIfFailed()
         .injectOpen(atOnceUsers(1));
}

The scenario fires a sequence of JMS messages with 5 sec intervals between them for about 30 sec total

Verification is at the end is…

public static PopulationBuilder checkJmsPerformanceStats() {
      return scenario("Check Stats")
         .exec(checkQueueStats())
         .injectOpen(atOnceUsers(1));
}

I log messages during the scenarios to figure out what was going on, it’s clear that the last step is firing early when no messages have been sent.

15:14:06.137 gatling-1-2 [INFO ] l.TestEnvironment - Setting up test environment
15:14:06.680 gatling-1-2 [INFO ] l.TestEnvironment - Checking that Counters are reset
15:14:07.158 gatling-1-4 [INFO ] l.TestEnvironment - Verify JMS Performance

================================================================================
2024-01-29 15:14:11                                           5s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=3      KO=1     )
> Validate Connections                                     (OK=1      KO=0     )
> Check that JMS Counters are reset                        (OK=1      KO=0     )
**> Verify JMS Performance                                   (OK=0      KO=1     )**
> Send OrderAccepted to STORE.ORDER-STATUS.FS              (OK=1      KO=0     )

Any idea what I might be doing wrong ?

First, as you don’t mention the version of Gatling you’re using, please make sure to use the latest one (3.10.3 as of now). You might be facing a bug that’s been already fixed.

Then, it’s impossible to tell what happens without you providing a proper reproducer.

Random shot in the dark: your scenario could be only shooting fire and forget send messages. In this case, it’s likely that your virtual users terminate way early than you expect;

Thanks for the quick reply, and it was something in my code and an older version of Gatling that allowed it.

Upgraded, fixed 2 type-compatibility issues and it’s all working now, I should have checked that first