Trouble with ResponseType when making a query-request using gRPC-calls

Hi,

My team is happily using Axon Framework for a while now. Recently we’ve started a little side-project in NodeJS. I’m aware that there’s currently no NodeJS client available for Axon Server, so I’ve tried to establish some means of communication between our SpringBoot/Kotlin api <-> NodeJS project with the help of gRPC calls.
After some digging I’ve found this repo: https://github.com/MGathier/axonserver-nodejs. This was very helpful in getting started. I’ve managed to open a stream and receive some events for instance. However, I’m having trouble making query-request.

This is the toObject() version of the call I’m making:

{
  messageIdentifier: 'b244e593-74b7-4dcb-92ae-a64fe77ac0ee',
  query: 'co.myapp.cqrs.SomeQuery',
  timestamp: 1600956188831,
  payload: {
    type: 'co.myapp.cqrs.SomeQuery',
    revision: '',
    data: 'PGNsaWVudElkPmY1NTI1MmQ1LTMzY2UtNDk3NC1iNGE1LTIwNjY2MDQ5ZjI4MjwvY2xpZW50SWQ+'
  },
  metaDataMap: [],
  responseType: { type: 'co.myapp.cqrs.SomeQueryResponse[]', revision: '', data: '' },
  processingInstructionsList: [],
  clientId: '30416@MacBook-Pro.local',
  componentName: 'nodejs-axon’
}

The response:

{
  messageIdentifier: '1c240136-f649-44ba-81e9-aebba99fc115',
  errorCode: 'AXONIQ-5001',
  errorMessage: {
    message: "class org.axonframework.serialization.UnknownSerializedType cannot be cast to class org.axonframework.messaging.responsetypes.ResponseType (org.axonframework.serialization.UnknownSerializedType and org.axonframework.messaging.responsetypes.ResponseType are in unnamed module of loader 'app')",
    location: '30091@MacBook-Pro.local',
    detailsList: [
      "class org.axonframework.serialization.UnknownSerializedType cannot be cast to class org.axonframework.messaging.responsetypes.ResponseType (org.axonframework.serialization.UnknownSerializedType and org.axonframework.messaging.responsetypes.ResponseType are in unnamed module of loader 'app')"
    ],
    errorCode: ''
  },
  payload: undefined,
  metaDataMap: [],
  processingInstructionsList: [],
  requestIdentifier: 'e7ca9db1-28f5-41a4-9d08-c62229be8680'
}

The query-handler looks like this:

@QueryHandler
fun handle(query: SomeQuery): Array<SomeQueryResponse> {  }

I’ve tried setting various response-types, ie. Array<co.myapp.cqrs.SomeQueryResponse> but none of them work.

Does anyone know how to get a successful response?

The responseType passed is not correct. This should have a type : org.axonframework.messaging.responsetypes.MultipleInstancesResponseType if the query returns multiple values and org.axonframework.messaging.responsetypes.InstanceResponseType if the query returns a single value, the data field in the response type is a serialized version of
{“expectedResponseType”: “co.myapp.cqrs.SomeQuery”}.

Hi Marc,
Thanks for your reply!
I’ve made the adjustments to the request as you’ve mentioned. This is the error I get in response:

class co.myapp.cqrs.SomeQueryResponse cannot be cast to class org.axonframework.messaging.responsetypes.ResponseType (co.myapp.cqrs.SomeQueryResponse and org.axonframework.messaging.responsetypes.ResponseType are in unnamed module of loader 'app')

I also tried to return a ‘simple’ response as a sanity check:

@QueryHandler
fun handle(query: SomeQuery): UUID {
    return UUID.randomUUID()
}

but than I get this error:

   'Cannot create UUID instance\n' +
        '---- Debugging information ----\n' +
        'message             : Cannot create UUID instance\n' +
        'cause-exception     : java.lang.IllegalArgumentException\n' +
        'cause-message       : Invalid UUID string: \n' +
        'class               : java.util.UUID\n' +
        'required-type       : java.util.UUID\n' +
        'converter-type      : com.thoughtworks.xstream.converters.SingleValueConverterWrapper\n' +
        'wrapped-converter   : com.thoughtworks.xstream.converters.basic.UUIDConverter\n' +
        'path                : /java.util.UUID\n' +
        'line number         : 1\n' +
        'version             : 1.4.11.1\n' +
        '-------------------------------',
      'Invalid UUID string: '

As I said earlier, I’m definitely not an Java / Kotlin expert :wink:
Any idea what I’m doing wrong?

Hi Erik,

We’ve got 80% of an Axonserver integration working using Nodejs and Typescript. Still need to implement saga and platform functionality, but quite happy with how command, query and event-bus are working.
Happy to share some knowledge if you are interested.

Cheers,
Arjan Noordhoek

1 Like

Hi Arjan,
Yes that would be great!
Ultimately I want to build an integration for NestJS. Maybe we can join forces? :slight_smile:

Erik