Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@cab105
Copy link
Contributor

I introduced a new runtime flag for spring-boot-migrator calledsbm.muleTriggerMeshTransformEnabled that 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 theK_SINK environment variable to the exposed transformation service.

I created agist to demonstrate what an integration within TriggerMesh would look like.

fabapp2 reacted with thumbs up emojifabapp2 reacted with eyes emoji
@fabapp2
Copy link
Contributor

@cab105 Thank you for your contribution!

I had three comments. Feel free to ping me if you want to discuss in person?

@cab105
Copy link
ContributorAuthor

cab105 commentedJul 7, 2022
edited
Loading

@cab105 Thank you for your contribution!

I had three comments. Feel free to ping me if you want to discuss in person?

Thank you for taking a look at@fabapp2 . Will address the rest template, tabs, and test issues, then resubmit.

fabapp2 reacted with rocket emoji

@sanagaraj-pivotal
Copy link
Contributor

Could we get an integration test for this feature, please referthis test for info

@cab105cab105force-pushed thetm-transformation branch 2 times, most recently from711359f to78f2ee8CompareAugust 7, 2022 22:20
@fabapp2
Copy link
Contributor

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?

@cab105
Copy link
ContributorAuthor

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.

@cab105
Copy link
ContributorAuthor

Resync from upstream main branch, added unit tests, and migrated the primary dataweave transformation into a template file.

@cab105
Copy link
ContributorAuthor

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")
Copy link
ContributorAuthor

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.

Copy link
Contributor

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 🚀

IntegrationTestBaseClass.beforeAll();

// Will need to ensure this is set globally for the test
System.setProperty("sbm.muleTriggerMeshTransformEnabled","true");
Copy link
ContributorAuthor

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.

Copy link
Contributor

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");
Copy link
ContributorAuthor

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.

Copy link
Contributor

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.

Copy link
Contributor

@fabapp2fabapp2 left a 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!

IntegrationTestBaseClass.beforeAll();

// Will need to ensure this is set globally for the test
System.setProperty("sbm.muleTriggerMeshTransformEnabled","true");
Copy link
Contributor

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()) {
Copy link
Contributor

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 :)

Copy link
Contributor

@fabapp2fabapp2 left a 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");
Copy link
Contributor

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.

@cab105
Copy link
ContributorAuthor

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...

It is. I originally used your approach of@Autowired onSbmApplicationProperties, but the unit test doesn't wire in theSbmApplicationProperties resulting in the tests to use the default behavior, and why I explicitly checked/set the System properties where I did. Granted if there was an easier way to pass a flag through the rewrite engine, then I'd be happy, but it appeared to require a lot more refactoring than I felt comfortable to pass the single flag down to the DwlTransformTranslator class.

@fabapp2
Copy link
Contributor

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...

It is. I originally used your approach of@Autowired onSbmApplicationProperties, but the unit test doesn't wire in theSbmApplicationProperties resulting in the tests to use the default behavior, and why I explicitly checked/set the System properties where I did. Granted if there was an easier way to pass a flag through the rewrite engine, then I'd be happy, but it appeared to require a lot more refactoring than I felt comfortable to pass the single flag down to the DwlTransformTranslator class.

The problem is that the test is not a@SpringBootTest and theSbmApplicationProperties would need to be added to theTestProjectContext test harness. But due to the inheritance design it is not (yet) possible.

What about...
you leave the property as it is, for now, fix the few comments left and we finally merge this back in?
And I will think about a way to remove the need for the application property.
Not 💯 sure yet how this will look like though...

cab105 reacted with thumbs up emoji

@fabapp2fabapp2 added the type: enhancementNew feature or request labelSep 23, 2022
@fabapp2fabapp2 added this to thev0.12.0 milestoneSep 23, 2022
@fabapp2fabapp2 linked an issueSep 23, 2022 that may beclosed by this pull request
@fabapp2fabapp2 merged commitcaab9e0 intospring-projects-experimental:mainSep 23, 2022
@cab105cab105 deleted the tm-transformation branchSeptember 23, 2022 18:43
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@fabapp2fabapp2fabapp2 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@cab105cab105

Labels

type: enhancementNew feature or request

Projects

None yet

Milestone

v0.12.0

Development

Successfully merging this pull request may close these issues.

Supports TriggerMesh for MuleSoft Dataweave Transformations

3 participants

@cab105@fabapp2@sanagaraj-pivotal

[8]ページ先頭

©2009-2025 Movatter.jp