xstefank / eventuate-tram-service

Testing application using new Eventuate Tram saga API
GNU Lesser General Public License v2.1
1 stars 2 forks source link

eventuate tram sample #2

Closed carloselpapa10 closed 6 years ago

carloselpapa10 commented 6 years ago

Hi xstefank,

I'm trying to test your Eventuate Tram sample since it looks interesting. I could start the application using docker and everything is ok. But I haven't been able to check the saga that you propose. I mean, once the createOrder method is executed with this json {"comment": "testComment", "price": 100, "productId": "testProduct"}

I only get this result.

[ { "id": "5ab236dcc44e7800075d35ef", "productInfo": { "productId": "testProduct", "comment": "testComment", "price": 100 }, "shipmentId": null, "invoiceId": null, "completed": false } ]

I think the shipmentId and invoiceId attributes shouldn't be null. right?

By the way, On the sample specification you wrote this url http://localhost:8080/order-service/order but the correct is http://localhost:8080/api/order.

Thanks in advance.

xstefank commented 6 years ago

Hello @carloselpapa10,

thanks a lot for trying this out!

I've updated versions a little, tried it locally and everything runs - shipment and invoice are ok. Can you please check that all of the services are running without errors (namely kafka, mysql, mongodb and business services - order, shipment, invoice). If you find any error you can post it here.

And thanks for the notice, this is a testing project for my diploma thesis and I forgot to update README after the API unification :+1:

carloselpapa10 commented 6 years ago

@xstefank thank you very much for your quick reply.

I'm testing it again and I get the same result. Everything seems to be ok. I do docker ps command to check all the services status. Also I do docker logs 'service-name' -f to check the log for each service. If for any reason one of them was deployed with errors I do docker restart 'name-service' command to fix it. Maybe I don't understand the program flow. In specific the Saga definition. I expect that each step on the Saga has done and if not get an error or compensation.

This is the output I get in orser-service. test

and these are the orders provided by getOrder method.

[ { "id": "5ab2bbaaa825190007ef356f", "productInfo": { "productId": "testProduct", "comment": "testComment", "price": 100 }, "shipmentId": null, "invoiceId": null, "completed": false }, { "id": "5ab2bcf6a825190007ef3570", "productInfo": { "productId": "testProduct", "comment": "testComment", "price": 100 }, "shipmentId": null, "invoiceId": null, "completed": false }, { "id": "5ab2bd8ba825190007ef3571", "productInfo": { "productId": "failShipment", "comment": "testComment", "price": 100 }, "shipmentId": null, "invoiceId": null, "completed": false } ]

what more can I do to reproduce the application? maybe I'm missing something.

Thanks in advance.

Anyway I have been reading some blogs from you and they are nice.

xstefank commented 6 years ago

Hi @carloselpapa10,

it looks like the Eventuates Kafka container is not running properly. Can you check the logs for eventuatesagas_kafka_1? The problem is that Eventuate as a platform runs on top of 4 or 5 containers which are all needed for the valid message propagation. In your case it really just looks like the Kafka topic is down and thus the message is not delivered to Shipment service.

If the issue persist, may I ask for the kafka container logs?

Thanks again!

carloselpapa10 commented 6 years ago

Hi @xstefank

You are right, the problem is between eventuatesagas_kafka_1 and eventuatesagas_zookeeper_1. I supposed that they were working fine. So finally I could see the complete Saga process of your sample even though sometimes those services failed constantly on my computer.

Thank you very much for your help.

carloselpapa10 commented 6 years ago

Hi @xstefank again,

I would like to know if you faced this kind of error since. I'm running the same code of you but in local and once the order saga gets the answer by other service it generates this error.

java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.eventuate.saga.orderservice.saga.OrderSagaData (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (String)"{"orderId":"5ab4ecb2cf9517439d6adac6","productInfo":{"productId":"testProduct","comment":"testComment","price":878376743}}"; line: 1, column: 2] at io.eventuate.javaclient.commonimpl.JSonMapper.fromJson(JSonMapper.java:37) ~[eventuate-client-java-common-impl-0.20.1.RELEASE.jar:na] at io.eventuate.tram.sagas.orchestration.SagaDataSerde.deserializeSagaData(SagaDataSerde.java:19) ~[eventuate-jpa-sagas-framework-0.5.0.RELEASE.jar:na] at io.eventuate.tram.sagas.orchestration.SagaInstanceRepositoryJdbc.findWithData(SagaInstanceRepositoryJdbc.java:159) ~[eventuate-jpa-sagas-framework-0.5.0.RELEASE.jar:na] at io.eventuate.tram.sagas.orchestration.SagaManagerImpl.handleReply(SagaManagerImpl.java:311) ~[eventuate-jpa-sagas-framework-0.5.0.RELEASE.jar:na] at io.eventuate.tram.sagas.orchestration.SagaManagerImpl.handleMessage(SagaManagerImpl.java:243) ~[eventuate-jpa-sagas-framework-0.5.0.RELEASE.jar:na] at io.eventuate.tram.consumer.kafka.MessageConsumerKafkaImpl.lambda$null$0(MessageConsumerKafkaImpl.java:52) [eventuate-tram-consumer-kafka-0.6.0.RELEASE.jar:na] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE] at io.eventuate.tram.consumer.kafka.MessageConsumerKafkaImpl.lambda$subscribe$1(MessageConsumerKafkaImpl.java:44) [eventuate-tram-consumer-kafka-0.6.0.RELEASE.jar:na] at io.eventuate.local.java.kafka.consumer.KafkaMessageProcessor.process(KafkaMessageProcessor.java:35) ~[eventuate-local-java-kafka-0.17.0.RELEASE.jar:na] at io.eventuate.local.java.kafka.consumer.EventuateKafkaConsumer.lambda$start$0(EventuateKafkaConsumer.java:92) ~[eventuate-local-java-kafka-0.17.0.RELEASE.jar:na] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_151]

I'd appreciate your help with this issue.

Thanks

xstefank commented 6 years ago

Hello @carloselpapa10,

this looks like the OrderSagaData is missing a no arguments constructor, which is required by FasterXML to deserialize incoming JSON. Currently, in the project I am using Lombok framework to generate constructor in the build (@NoArgsConstructor annotation). Did you build the project with gradle wrapper? If it doesn't help, you can remove @NoArgsConstructor annotation from OrderSagaData class and add a simple empty constructor to it manually:

public OrderSagaData() {
}
carloselpapa10 commented 6 years ago

Hello @xstefank ,

I'm using maven to build the projects. I just realize that it works as a docker images. I have been spending time on the same error. My doubt would be do I need to dockerize the project to test the Saga steps? wow I can't check why.. and this error seems like the problem would be other...

Anyway, thank you very much...

xstefank commented 6 years ago

Hello @carloselpapa10,

so you've rewritten the build system to use Maven? (you can easily build it with gradle ;) ) Interesting question. Well, you don't need to use docker, but the Eventuate platform is set up on it. I've never tried to go without it, as docker compose is simpler and quicker for development. You can somehow put all eventuate services somewhere in open, but you need to check their internal configuration how they communicate as docker-compose creates internal network for them. The same applies to my saga services, you need to update configuration files with the correct locations.

And back to the original question - if you rewritten it to use Maven, you need to include Lombok as a dependency (you can check build.gradle, it should be somewhere)

maven lombok - https://projectlombok.org/mavenrepo/index.html

Hope this helps!

carloselpapa10 commented 6 years ago

Hi @xstefank,

About Gradle or Maven, I have both but I'm working with maven since some time ago. That's not the problem.

About the Eventuate platform. I use Docker to build it. But I want to test my services while I'm developing them. For instance, I want to test both order-service and invoice-service through my Eclipse IDE to check the interaction between them. I set all the Eventuate configuration in the properties file for each service and the deployment is fine. The problem is when the Saga procedure is executed. From local I got the error I wrote above but the same services on Docker work fine.

Could you test your services in local (i.e. in your IDE) when you were developing them?

Thanks again!

xstefank commented 6 years ago

@carloselpapa10, the problem above is explained in the previous comment, you need to include lombok in your build or you need to put a default (no arguments) constructor into OrderSagaData so FasterXML can process JSON you are sending.

If I can recommend, you if you want to debug a Spring Boot application in Docker -- https://stackoverflow.com/questions/24113939/how-to-debug-spring-boot-application-with-eclipse the second answer should do the trick for you. You need to include debug info in the Docker container, but if you check https://github.com/xstefank/eventuate-sagas/blob/master/order-service/Dockerfile#L5 you'll see that Docker is not doing any magic :) just add the debug switches from SO question and you can setup remote debug in Eclipse into the container.

The problem what I see with your approach is, that docker-compose creates a network behind its execution, that is why you can simple say invoice-service:8080 in order-service code, because the address resolution will be done by docker. This is just a heads up, if you'll go forward with your starting from IDE.

Let me know if I can help any further, but if I don't see your setup, I cannot reporduce the issues :) (btw, IDE may be doing some magic on the background, even this is why I prefer terminal:) )

carloselpapa10 commented 6 years ago

@xstefank,

I added the lombok dependency once I switched to maven. Here, you can see my small sample. https://github.com/carloselpapa10/mainclass/tree/master/5.%20Eventuate%20TRAM

About the IDE, you are completely right, ;)

xstefank commented 6 years ago

and you still have the java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.eventuate.saga.orderservice.saga.OrderSagaData error? Sorry, but you project cannot be compiled with the specified steps, and I don't have time to fix it.

xstefank commented 6 years ago

Hey @carloselpapa10,

any progress? :) can this be closed or do you want further help?

carloselpapa10 commented 6 years ago

@xstefank yes, actually this material was really helpful in my beginning with Eventuate Framework.. Thanks for everything...

xstefank commented 6 years ago

@carloselpapa10 no worries, glad to help!