I get the below-mentioned exception thrown from saga event handler. I have configured distributed command bus using spring cloud connector, and whenever a command is dispatched from saga event handler using the command gateway this exception id thrown.
This ‘conversion exception’ only occurs when the PlaceOrderCommand is published from a Saga?
Thus, you’ve got a use case were the PlaceOrderCommand is published from a non-event-handling-component (I regard a Saga as an Event Handling Component as it’s triggered by events) which does work?
And just to be clear, this exception is thrown on the sending side of that command, not on the receiving side, correct?
Could you share a more elaborate stack trace of the exception you’re getting?
Maybe that contains some info which I can help you out with, since with the current snippets you’ve shared I’m kinda at a loss.
My general knowledge of XStream is that it is very good at serializing about everything, so I’m kinda surprised you’ve got this exception.
Let’s try to figure this out; interested what the problem is here!
Actually, PlaceOrderCommand is published from non-event-handling component and not from saga event handler. And PlaceOrderCommand results in OrderPlacedEvent from ShoppingCart aggregate.
Weird, would’ve expected you’d receive more.
A quick google on the ConversionException you’re receiving however does not give any concrete answers to what is going wrong here…
I’d assume though this issue has nothing to do with using the DistributedCommandBus or the Spring Cloud CommandBusConnector/CommandRouter for that matter…
As I suggested in my first response, it might be a good idea to confirm that, by checking if you get the same warning if you publish the PlaceOrderCommand on a CommandBus implementation which does not publish to another node.
I’d however rather say this lies with XStream and how your PlaceOrderCommand is modeled.
What does your PlaceOrderCommand look like, implementation wise?
And one other thing, are your Axon nodes homogeneous or heterogeneous?
the error shows that XStream is complaining about an HTTP Cache related object. That indicates the class references something that you probably didn’t intend to.
You said the class only references two objects. Is that class perhaps a non-static inner class? Or are you using some (annotation based) enhancers like Lombok? In that case, you might be implicitly referencing other classes as well.
By the way, your first exception showed a different error, where it complained about a concurrent collection. Which fields do you expect your object to contain?
It’s most likely because the message or metadata contains information that XStream cannot (de)serialize. There is probably a detailed stacktrace somewhere indicating where the problem is.
Seems like XStream cannot serialize something.
The only ‘known issue’ with XStream related exceptions is when you have a Saga with a field that contains an infrastructure component which is not declared transient.
Note that the SagaTestFixture checks this.
I am using Axon4.2 with Spring boot. Created simple saga. Its works well during Application running. However once it restarts, it re-runs the Saga again.
So Tried to use MongoSagaStore for persisting SgagStore, did not work. Below are code snippet. Please help.
@Configuration
public class AxonConfig {
@Bean
@Primary
public Serializer serializer() {
final XStream xStream = new XStream(new CompactDriver());
xStream.setClassLoader(this.getClass().getClassLoader());
return XStreamSerializer.builder().xStream(xStream).build();
}
@Bean
public MongoSagaStore sagaStore(MongoClient client) {
MongoSagaStore.Builder builder = new MongoSagaStore.Builder();
builder.mongoTemplate(DefaultMongoTemplate.builder()
.mongoDatabase(client).build());
return builder.build();
}
i modified MongoSagaStore. below is the code snipped and it worked for me.
we need use builder.serializer(JacksonSerializer.defaultSerializer()); then we wont get that exception.
@bean
public SagaStore sagaRepository(MongoClient mongoClient) {
MongoSagaStore.Builder builder = new MongoSagaStore.Builder();
builder.mongoTemplate(DefaultMongoTemplate.builder()
.mongoDatabase(mongoClient).build());
builder.serializer(JacksonSerializer.defaultSerializer());
return builder.build();
}
the problem with the Saga getting the events again is probably the cause of the TokenStore being used. Axon defaults to Tracking Processing, and if it can’t find any location to store the tokens in, it uses an InMemoryTokenStore. Try configuring a TokenStore implementation in your application context.