SubscriptionQueryResult return empty data Axon 4

Hi. I’m trying to create a simple reactive application. I’ve written a class to handle the query operations.
I’ve written a get request controller.

`

@GetMapping(path = “”, produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
public Flux<List> getOrganizationCollection() {
SubscriptionQueryResult<List, OrganizationViewModel> queryResult = subscribeToOrganizationCollection();
return queryResult.initialResult().doOnError(e -> {
throw new RuntimeException(e);
}).concatWith((Publisher<? extends List>) queryResult.updates());
}

`

encapsulate the subscriptor

`

private SubscriptionQueryResult<List, OrganizationViewModel> subscribeToOrganizationCollection() {
AllOrganizationQuery query = AllOrganizationQuery.builder().build();
SubscriptionQueryResult<List, OrganizationViewModel> queryResult = queryGateway
.subscriptionQuery(query, ResponseTypes.multipleInstancesOf(OrganizationViewModel.class),
ResponseTypes.instanceOf(OrganizationViewModel.class));
return queryResult;
}

`

the emitter

`
queryUpdateEmitter.emit(AllOrganizationQuery.class, query -> true, viewModel);

`

and at last, the query handler

`

@QueryHandler
public List handle(AllOrganizationQuery query) {
return new ArrayList(eventHappened.values());
}

`

When I do the Http request I get the following empty result

EmptyResult.PNG

Debbuging the code, I’ve noticed that the data propperty from SubscriptionQueryResult is an view model class instance with empty values. Digging a little bit more, I’ve seen that data has been lost when Axon Serialize to binary the queryhandler result. (I’m using Jackson Serializer)

Any Idea about that?

If I work with String type instead of view model class type, it works fine

Thank you in advance

Hi Carlos,

it seems that Jackson serializes your view model to an empty object. Is your viewmodel class structure Jackson compatible? For example, does it have getters for the properties to serialize?

Cheers,

Allard

EmptyResult.PNG

Thanks Allard, That is problem. I’m using lombok and it seems there are a kind of confict between lombok and jackson

In case someone else has the same problem, I added this annotation to my view model class definition and it works fine

`

@JsonAutoDetect(fieldVisibility = Visibility.ANY)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)

`

I’ll dig more whether there are other alternative configurations to avoid specify this visibility annotations

thanks!