I have two projects which work with axon server, each projet configured by a context
project A → context1
project B → context2
I tried to send a command from the project A to project B
I added the below config in the project A
@Bean
public TargetContextResolver<?> targetContextResolver() {
return message -> message.getPayloadType().getName().startsWith("com.am") ? "context2" : "context1";
}
application.yml project A
axon:
serializer:
general: jackson
events: jackson
messages: jackson
deserializer:
general: jackson
events: jackson
messages: jackson
axonserver:
clientId: context1
keep-alive-time: 1000
sslEnabled: true
context: context1
servers: node.axonserver-test.local
token: xxxxxxxxx
application.yml project B
axon:
serializer:
general: jackson
events: jackson
messages: jackson
deserializer:
general: jackson
events: jackson
messages: jackson
axonserver:
clientId: context2
keep-alive-time: 1000
sslEnabled: true
context: context2
servers: node.axonserver-test.local
token: xxxxxxxxx
but i have this error
Caused by: org.axonframework.serialization.SerializationException: Error while deserializing object
at org.axonframework.serialization.json.JacksonSerializer.deserialize(JacksonSerializer.java:207)
at org.axonframework.serialization.LazyDeserializingObject.getObject(LazyDeserializingObject.java:102)
at org.axonframework.axonserver.connector.command.GrpcBackedCommandMessage.getPayload(GrpcBackedCommandMessage.java:83)
at org.axonframework.modelling.command.AnnotationCommandTargetResolver.invokeAnnotated(AnnotationCommandTargetResolver.java:133)
at org.axonframework.modelling.command.AnnotationCommandTargetResolver.findIdentifier(AnnotationCommandTargetResolver.java:115)
at org.axonframework.modelling.command.AnnotationCommandTargetResolver.resolveTarget(AnnotationCommandTargetResolver.java:92)
at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:567)
at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:557)
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:57)
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
at org.axonframework.messaging.interceptors.LoggingInterceptor.handle(LoggingInterceptor.java:85)
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
at org.axonframework.messaging.interceptors.CorrelationDataInterceptor.handle(CorrelationDataInterceptor.java:67)
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:77)
at org.axonframework.commandhandling.SimpleCommandBus.lambda$handle$3(SimpleCommandBus.java:198)
at org.axonframework.tracing.Span.run(Span.java:72)
at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:189)
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:163)
at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:130)
at org.axonframework.axonserver.connector.command.AxonServerCommandBus$CommandProcessingTask.run(AxonServerCommandBus.java:308)
at org.axonframework.axonserver.connector.PriorityRunnable.run(PriorityRunnable.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (byte[])"<com.am.domain.commands.InitCommand><id>54757787</id><processId>35f1e845-b8e9-11ed-a1f9-fa163eacb093</processId><processVariables/></com.am.domain.commands.InitCommand>"; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:735)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:659)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2737)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:902)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:794)
at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:356)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2041)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1529)
at org.axonframework.serialization.json.JacksonSerializer.deserialize(JacksonSerializer.java:205)