Can't make AxonServer Integration work for a simple query

Hi,

I am trying to make my Go application work with AxonServer Integration (I understand that’s the replacement for Synapse), but I am having some difficulties to make a simple query handler work.

So basically the repo can be found here.
In this repo I generated the go models based on the openapi spec, and then I have a small go application in example/simple in which I will try to register an endpoint and a query handler.

As a summary,
0. Run my go app localhost:8081, and axonserver localhost:8024.

  1. The go app registers an endpoint.
  2. also registers a query handler for the query name GetUserByIDQuery.
  3. I run a query for that name, but I get Retries exhausted 1/1.

I created a small client.http (inside examples/simple/client.http) in which I try to do the previous steps without running my go application, so then it’s easy to check the values that I am sending.
Can you check whether the values I put make sense?

I was also checking the documentation, but I think there are several mistakes in it, e.g:

  • I see several v1 references, like: The Raw endpoint URL path follows the /v1/queries/[queryName]?context=[contextName] when I think all of them should be v2 (actually the endpoint does not work if I use v1)
  • When visiting the integration-api it’s not well displayed in my browser (Chrome).

Also, I am generating the go models from the openapi spec, but when generating them I am getting some incosistencies, like in some cases the endpoint is a string, and in other an uuid, and it’s a bit annoying to work with it (I can take a look better at it), but I am guessing other languages don’t have that issue?

Hi, you should be able to go to http://localhost:8024/swagger-ui/index.html and switch to Integration specs api (http://localhost:8024/v3/api-docs/integration)

Or go directly to the url:

http://localhost:8024/swagger-ui/index.html?urls.primaryName=Axon+Server+API+-+Integration#/Integration/dispatchQuery

Here specs are correct, thanks for pointing to the bug in the docs!

Here is a curl call that will dispatchQuery correctly:

curl -X 'POST' \
  'http://localhost:8024/v2/queries?context=default' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "io.axoniq.multitenancy.api.FindAllCardsQuery",
  "numberOfResponses": 1,
  "responseCardinality": "MULTIPLE",
  "responseType": "io.axoniq.multitenancy.api.GiftCardRecord",
  "responseTypeEncoding": "application/json",
  "id": "50534a63-49e4-4646-b25a-6816405c4539",
  "metaData": {
    "tenantId": "tenant-test"
  },
  "payload": {},
  "payloadType": "io.axoniq.multitenancy.api.FindAllCardsQuery",
  "payloadRevision": null,
  "payloadContentType": "application/json"
}'

Hi @stefand, thanks for your answer.

So I was able to move a bit forward. Now I am able to register my query handler, and even reply to queries sent through http

POST http://localhost:8024/v2/queries?context=default
accept: application/json
Content-type: application/json

{
  "id": "{{$uuid}}",
  "name": "org.github.manuelarte.axongo.example.api.GetUserByIDQuery",
  "numberOfResponses": 1,
  "responseCardinality": "SINGLE",
  "responseType": "org.github.manuelarte.axongo.example.api.UserRead",
  "responseTypeEncoding": "application/json",
  "payloadType": "org.github.manuelarte.axongo.example.api.GetUserByIDQuery",
  "payloadContentType": "application/json",
  "payload": {
    "id": 1
  }
}

Now my next step is trying to integrate a Spring Boot App and a Go app through AxonServer Integration, but I am having some difficulties.

If I run my spring boot app, register a query handler for my query org.github.manuelarte.axongo.example.api.GetUserByIDQuery, and then run the following http call:

POST http://localhost:8024/v2/queries?context=default
accept: application/json
Content-type: application/json

{
  "id": "{{$uuid}}",
  "name": "org.github.manuelarte.axongo.example.api.GetUserByIDQuery",
  "numberOfResponses": 1,
  "responseCardinality": "SINGLE",
  "responseType": "org.github.manuelarte.axongo.example.api.UserRead",
  "responseTypeEncoding": "application/json",
  "payloadType": "org.github.manuelarte.axongo.example.api.GetUserByIDQuery",
  "payloadContentType": "application/json",
  "payload": {
    "id": 1
  }
}

I get a response like the following:

{
  "id": "31097894-0ed9-4d4b-83be-4794a799f313",
  "metaData": {
    "traceId": "0d1b0d13-467e-4a94-b4d9-6002cb2d43e0",
    "correlationId": "0d1b0d13-467e-4a94-b4d9-6002cb2d43e0"
  },
  "payload": {
    "id": 1,
    "name": "John",
    "surname": "Doe"
  },
  "payloadType": "org.github.manuelarte.axongo.example.api.UserRead",
  "payloadRevision": ""
}

Which is good (special check to the field metaData), and I get a very similar response, if instead of running my spring boot app, I run my go-app:

{
  "id": "12f0fee8-5605-4b0a-965f-fc2edf0fd54e",
  "metaData": {},
  "payload": {
    "id": 1,
    "name": "John",
    "surname": "Doe"
  },
  "payloadType": "org.github.manuelarte.axongo.example.api.UserRead",
  "payloadRevision": ""
}

The metaData field is not set.

But the problems come here, if I now run my spring-boot app with only the profile api (so the query handler is not registered), and my go-app with the query handler registered, then I get the following error in my spring-boot app when trying to do a query:

org.axonframework.axonserver.connector.query.AxonServerQueryDispatchException: CANCELLED: Not supported for integration endpoints
	at org.axonframework.axonserver.connector.ErrorCode.lambda$static$17(ErrorCode.java:123) ~[axon-server-connector-4.11.2.jar:4.11.2]
	at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:201) ~[axon-server-connector-4.11.2.jar:4.11.2]
	at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:232) ~[axon-server-connector-4.11.2.jar:4.11.2]
	at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:221) ~[axon-server-connector-4.11.2.jar:4.11.2]
	at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
...

Any idea why? do you think it’s related to not having the metaData field filled with the original request id?

And, in case it’s because of the metaData, how can I “populate” that field? (for example, I also needed to manually populate the field payloadType, and I did it through the header AxonIQ-PayloadType, link)

Thanks.