-
Notifications
You must be signed in to change notification settings - Fork 90
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 our terms of service and privacy 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
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
Outdated
Show resolved
Hide resolved
...ava/org/springframework/sbm/mule/actions/javadsl/translators/dwl/DwlTransformTranslator.java
Show resolved
Hide resolved
...ava/org/springframework/sbm/mule/actions/javadsl/translators/dwl/DwlTransformTranslator.java
Outdated
Show resolved
Hide resolved
Could we get an integration test for this feature, please refer this test for info |
f265415
to
da0fef5
Compare
711359f
to
78f2ee8
Compare
Hi @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. |
a376ef0
to
31c1533
Compare
Resync from upstream main branch, added unit tests, and migrated the primary dataweave transformation into a template file. |
b451850
to
acc51b9
Compare
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)? |
acc51b9
to
ab033a9
Compare
ab033a9
to
d31c0d3
Compare
f1fac5d
to
fa7bf11
Compare
fa7bf11
to
7fa4a62
Compare
import static org.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.java
Show resolved
Hide resolved
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.
@@ -60,13 +91,19 @@ public DslSnippet translate( | |||
String flowName, | |||
Map<Class, MuleComponentToSpringIntegrationDslTranslator> translatorsMap | |||
) { | |||
// Ugly hack to work around an inability to inject a sbm property into the mulesoft parser. | |||
String isTmTransformationEnabled = 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
@Autowired
private 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.java
Show resolved
Hide resolved
...-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/actions/JavaDSLAction2.java
Outdated
Show resolved
Hide resolved
...hell/src/test/java/org/springframework/sbm/MigrateSimpleMuleAppDataweaveIntegrationTest.java
Show resolved
Hide resolved
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.
String description = "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...
@@ -60,13 +91,19 @@ public DslSnippet translate( | |||
String flowName, | |||
Map<Class, MuleComponentToSpringIntegrationDslTranslator> translatorsMap | |||
) { | |||
// Ugly hack to work around an inability to inject a sbm property into the mulesoft parser. | |||
String isTmTransformationEnabled = 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
@Autowired
private 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.muleTriggerMeshTransformEnabled
that will modify the generated mule-to-boot recipe for handling DataWeave transformations to stream the transformation to TriggerMesh'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_SINK
environment variable to the exposed transformation service.I created a gist to demonstrate what an integration within TriggerMesh would look like.