AF5 query handlers returns wrong result to AF3 client

Hello,

I’ve been working for some time now on migrating our applications from AF4 to AF5. Along the way I’ve already run into a number of bugs, and had been waiting for fixes in newer Axon versions.

Since we have several apps and I don’t want to deploy all of them as AF5 apps at once, I’m trying to run AF4 and AF5 apps mixed together. Of course that’s only meant to be temporary, but from my point of view it should fundamentally work for a reasonable migration.

I had most recently paused the migration because of Query Handlers returning `Optional` between AF4 and AF5 are incompatible · Issue #4744 · AxonIQ/AxonFramework · GitHub, since we have quite a few queries with Optional as the result. That issue has now been fixed in 5.2.1, so I wanted to continue migrating.

However, I immediately ran into the next query incompatibility. I’m surprised that apparently no one else has run into this problem, since from my perspective it’s really simple and basic.

We have QueryHandlers that return a List:

class CustomerFindPageQuery

data class CustomerDto(
  val customerId: String,
  val name: String,
)

@QueryHandler
fun handle(query: CustomerFindPageQuery): List<CustomerDto> {
  return customers.values.toList()
}

When I call the query, I get different results for AF4 and AF5 clients:

AF5 client:

  queryGateway.queryMany(
    CustomerFindPageQuery(),
    CustomerDto::class.java
  )

=> full list of customers

AF4 client:

  queryGateway.query(
    CustomerFindPageQuery(),
    ResponseTypes.multipleInstancesOf(CustomerDto::class.java)
  )

=> only 1 element returned

I’m a bit puzzled that this doesn’t work, since almost every AF4 application querying against an AF5 QueryHandler would then have to be broken.

Of course, it’s a bit silly that I only spotted this problem now and not earlier, when I reported the issue with the Optional result. But I hadn’t actually gotten to these “real” queries in my testing before, because the Optional queries came first. Sorry, Steven

Did I misunderstand something? Is there a configuration option I’m missing? Or am I just a bit stupid? :slight_smile:

Klaus

To reproduce, here is a simple repo: GitHub - klauss42/axon5-simple · GitHub

I just saw that there is a typo in the title of this post. Of course it should be “AF4” and not “AF3”. Seems that I cannot edit the titleof my posting :frowning:

Thanks, Klaus, but no worries! :wink:
We’re only human after all.

Nope, as far as I see, this would indeed be a normal use case to me. Could you perhaps construct a sample application that consistently shows this faulty behavior, just as you did the last time? That would help us pinpoint the exact issue a lot quicker.

Hi Steven,
yes, I added this issue to my little test scenario repo GitHub - klauss42/axon5-simple · GitHub

Klaus

Thanks a ton, @klauss42!

I’ll give it a look…together with Convert message handlers to right MessageStream cardinality by CodeDrivenMitch · Pull Request #4940 · AxonIQ/AxonFramework · GitHub which we only recently spotted ourselves too. I am guessing that is the predicament you are facing as well. If it solves things for us, I’ll test it against your sample repository and report back.

I was able to reproduce the issue, @klauss42.
The PR I mentioned, however, does not solve it.
Luckily, I have a guestimate what it might be. Hence, I am investigating.
I’ll come back here if I have something helpful for you.

Got a PR resolving it, which you can find here.
The PR is slated for 5.4.0, but we’ll backport it to 5.3.
Although the team is tied a bit (due to vacation), I am pretty confident I can get everything reviewed on time to have it be part of 5.3.1, which we intend to release tomorrow.

Hey Steven. Great news. Thanks

Fix is merged, and it’s been released in 5.3.1. Local testing against your sample app proved successful, but please do give it a try and let us know if your issues are resolved, @klauss42!

Confirmed for my little test app. I have to check with whole applications later. Thanks Steven