- Notifications
You must be signed in to change notification settings - Fork100
Add support for generating code to send MuleSoft Dataweave Transformations to TriggerMesh#183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Add support for generating code to send MuleSoft Dataweave Transformations to TriggerMesh#183
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@cab105 Thank you for your contribution! I had three comments. Feel free to ping me if you want to discuss in person? |
...ava/org/springframework/sbm/mule/actions/javadsl/translators/dwl/DwlTransformTranslator.java OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...ava/org/springframework/sbm/mule/actions/javadsl/translators/dwl/DwlTransformTranslator.javaShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...ava/org/springframework/sbm/mule/actions/javadsl/translators/dwl/DwlTransformTranslator.java OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cab105 commentedJul 7, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Could we get an integration test for this feature, please referthis test for info |
711359f to78f2ee8CompareHi@cab105 Are you facing issues with this? If you like we can pair to get the last few bits added and this PR merged? |
The codebase has been pretty unstable due to the springboot 3 work, but does look like it has now solidified, and am identifying issues with my original test code that need to be addressed. Once that is resolved, then we should be good to go. |
Resync from upstream main branch, added unit tests, and migrated the primary dataweave transformation into a template file. |
So I've been able to resolve some of my outstanding issues, and have fixed a couple of issues in SBM proper (#385 and#373). Given the current Mule integration test that was cited in the comments is disabled due to#351, I'm wondering if there's anything else that would be required for this PR (save for a resync with upstream)? |
| importstaticorg.assertj.core.api.Assertions.assertThat; | ||
| @TestMethodOrder(MethodOrderer.MethodName.class) | ||
| //@Disabled("Temporary disabled before CI will be fixed with docker in docker issue: #351") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looking at the base test, this annotation is in effect, but left it commented out to facilitate verification for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not sure if I get you here, but the method order is obsolete as there's only one test and no shared state, or?
You can remove the commented@Disabled, the test is green 🚀
...hell/src/test/java/org/springframework/sbm/MigrateSimpleMuleAppDataweaveIntegrationTest.javaShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| IntegrationTestBaseClass.beforeAll(); | ||
| // Will need to ensure this is set globally for the test | ||
| System.setProperty("sbm.muleTriggerMeshTransformEnabled","true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I looked into overriding@SpringProperties, but this would not get picked up by the transformer that would swap out the stub code for the code that will send the transformation out to the TriggerMesh Dataweave transformer. If there's a cleaner way to do this, then would appreciate hearing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think we should rework this approach and set the flag in the action of a dedicated recipe, e.g.migrate-mule-to-boot-tm and then just call it from here.
| Map<Class,MuleComponentToSpringIntegrationDslTranslator>translatorsMap | ||
| ) { | ||
| // Ugly hack to work around an inability to inject a sbm property into the mulesoft parser. | ||
| StringisTmTransformationEnabled =System.getProperty("sbm.muleTriggerMeshTransformEnabled"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Required to work around case when running unit test and@Autowired is unable to bring in the SBM properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Technically speaking, this should work
@Autowiredprivate SbmApplicationProperties p;public void m() { p.getPropertyXyz();}But in this case an annotation on type level@ConditionalOnProperty(name = "sbm.muleTriggerMeshTransformEnabled", havingValue = "true") of a dedicated implementation would would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hi@cab105 !
Thanks for your effort! 🚀
I think the hacky ;) bits will disapear as soon as the application property is removed and the action gets parametrized per recipe, which feels somehow naturally (now).
Everything else lgtm!
...-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/actions/JavaDSLAction2.javaShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/actions/JavaDSLAction2.java OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...hell/src/test/java/org/springframework/sbm/MigrateSimpleMuleAppDataweaveIntegrationTest.javaShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| IntegrationTestBaseClass.beforeAll(); | ||
| // Will need to ensure this is set globally for the test | ||
| System.setProperty("sbm.muleTriggerMeshTransformEnabled","true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think we should rework this approach and set the flag in the action of a dedicated recipe, e.g.migrate-mule-to-boot-tm and then just call it from here.
| Stringdescription ="Migrate Mulesoft 3.9 to Spring Boot."; | ||
| // Flag to enable TriggerMesh ransformation mode | ||
| if (sbmProperties.isMuleTriggerMeshTransformEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We should better create two bean methods here, calling one factory method that creates the recipe twice with the flag true and false. Taht would then finally allow to remove the application property :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I just realize that there must be some way to toggle these translators if boot creates them...
but it should not be an application/system property when possible...
it should come from the recipe/action...
this could be tricky...
| Map<Class,MuleComponentToSpringIntegrationDslTranslator>translatorsMap | ||
| ) { | ||
| // Ugly hack to work around an inability to inject a sbm property into the mulesoft parser. | ||
| StringisTmTransformationEnabled =System.getProperty("sbm.muleTriggerMeshTransformEnabled"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Technically speaking, this should work
@Autowiredprivate SbmApplicationProperties p;public void m() { p.getPropertyXyz();}But in this case an annotation on type level@ConditionalOnProperty(name = "sbm.muleTriggerMeshTransformEnabled", havingValue = "true") of a dedicated implementation would would be better.
It is. I originally used your approach of |
The problem is that the test is not a What about... |
I introduced a new runtime flag for spring-boot-migrator called
sbm.muleTriggerMeshTransformEnabledthat will modify the generated mule-to-boot recipe for handling DataWeave transformations to stream the transformation toTriggerMesh's Dataweave Transformer.The generated code works best when the service runs inside a Kubernetes cluster leveraging Knative's Sink Binding to associate the the newly migrated service to the TriggerMesh Dataweave transformation, however the service can run on it's own by setting the
K_SINKenvironment variable to the exposed transformation service.I created agist to demonstrate what an integration within TriggerMesh would look like.