-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add Groovy Hello World sample implementation #370
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 Groovy Hello World sample implementation #370
Conversation
This commit introduces a new Hello World sample specifically designed for Groovy developers. The sample demonstrates basic Spring Integration concepts using Groovy DSL and provides two runnable applications. Changes include: - Add `helloworld-groovy` project with Groovy DSL configuration - Implement HelloWorldApp and PollerApp examples - Configure Groovy dependencies and spring-integration-groovy module - Add runHelloWorldApp and runPollerApp Gradle tasks for execution - Update developer information in build.gradle POM configuration
artembilan
left a comment
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.
Some minor nit-picks.
Thank you!
| } | ||
|
|
||
| @Bean | ||
| Executor executor() { |
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.
This bean looks like out of use.
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 added it blindly, because it was in the original. Will remove.
| { e -> e.poller(Pollers.fixedDelay(20000).maxMessagesPerPoll(2)) }) | ||
| { | ||
| log LoggingHandler.Level.INFO, 'org.springframework.integration.samples.helloworld' | ||
| channel { queue 'loggerChannel' } |
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.
You already have logged the data.
Perhaps nullChannel() is what we need in the end.
| } | ||
|
|
||
| @Bean | ||
| IntegrationFlow helloWorldFlow(@Qualifier('inputChannel') MessageChannel input, |
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 Groovy is smart enough to let us to not specify a return type on bean methods.
build.gradle
Outdated
| roles = ['project founder and lead emeritus'] | ||
| } | ||
| developer { | ||
| id = 'glennrenfro' |
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 this is supposed to be your GH account.
artembilan
left a comment
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.
Forgot to mention: we need some tests to be sure that our Groovy code is working.
...roovy/src/main/groovy/org/springframework/integration/samples/helloworld/PollerConfig.groovy
Show resolved
Hide resolved
...roovy/src/main/groovy/org/springframework/integration/samples/helloworld/PollerConfig.groovy
Show resolved
Hide resolved
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| context = new AnnotationConfigApplicationContext(HelloWorldConfig) |
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 believe @SpringJUnitConfig works well with Groovy, too.
We don't need these pair of infra methods.
You can point to that HelloWorldConfig from the annotation.
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.
This was not addressed
| inputChannel.send(new GenericMessage<String>('World')) | ||
| def message = outputChannel.receive(1000) | ||
| assertNotNull(message, 'Message should not be null') | ||
| assertEquals('Hello World', message.payload) |
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 prefer AssertJ instead of JUnit native assertions.
| loggerContext.getRootLogger().addAppender(listAppender) | ||
| loggerContext.updateLoggers() | ||
|
|
||
| context = new AnnotationConfigApplicationContext(PollerConfig) |
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.
Same here about @SpringJUnitConfig.
If we go a ListAppender way, then it might be better to configure it only once for all the tests using @BeforeAll/@AfterAll.
Otherwise this test class share some bad practice with Spring.
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.
spring-integration-core can be removed as this project picks it up from spring-integration-groovy'. However, log4j-core` is only declared in projects that need it.
* Update PR per code review comments. * Remove dependencies that are picked up transitively * Update JUnit version
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| context = new AnnotationConfigApplicationContext(HelloWorldConfig) |
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.
This was not addressed
This commit introduces a new Hello World sample specifically designed for Groovy developers. The sample demonstrates basic Spring Integration concepts using Groovy DSL and provides two runnable applications.
Changes include:
helloworld-groovyproject with Groovy DSL configuration