-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add file-split-ftp Sample #177
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
Conversation
Well, welcome back and your test have been failed 😄
|
9eebe3d
to
434e017
Compare
Strange, runs fine with gradle for me locally; re-pushed with top level README update. Let's see... |
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.
That's all. Just several nit-picking to consider or just discuss. But I won't mind if you address them in subsequent commit.
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>vg</artifactId> |
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 need POM in this project any way, but that should be correct one based on the group = 'org.springframework.integration.samples'
} | ||
|
||
task run(type: JavaExec) { | ||
main 'org.springframework.integration.samples.barrier.Application' |
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.
Wrong class name. In both places.
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
@SpringBootApplication | ||
@EnableConfigurationProperties(MailProperties.class) |
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.
Seems for me we don't need this.
It is a part of MailSenderAutoConfiguration
.
I won't mind if I miss something. Then any explanations are welcome.
Thanks
} | ||
|
||
private PayloadTypeRouter ptr() { | ||
PayloadTypeRouter payloadTypeRouter = new PayloadTypeRouter(); |
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.
Nit-picking, of course, but can't we rely on the Java DSL 1.2 here already:
.<Object, Class<?>>route(Object::getClass, m -> m
.channelMapping(FileSplitter.FileMarker.class, "markers.input")
.channelMapping(String.class, "lines.input"))
?
@Bean | ||
public IntegrationFlow markers() { | ||
return f -> f.<FileSplitter.FileMarker>filter(m -> m.getMark().equals(FileSplitter.FileMarker.Mark.END), | ||
e -> e.id("markerFilter").discardChannel("nullChannel")) // INT-4109 |
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.
https://jira.spring.io/browse/INT-4109 has been fixed and Samples is on the SI-4.3.2 already.
.handleWithAdapter(a -> a.ftp(ftp3()).remoteDirectory("foo"), e -> e.id("ftp009"))) | ||
|
||
// send an email | ||
.subscribe(sf -> sf.<FileSplitter.FileMarker, String>transform(p -> p.getFilePath()) |
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.
My IDEA says that can be replaced with method reference:
.subscribe(sf -> sf.transform(FileSplitter.FileMarker::getFilePath)
StringBuilder builder = new StringBuilder(); | ||
builder.append(p.getFailedMessage().getPayload().toString()).append("\n") | ||
.append(getStackTraceAsString(p)); | ||
return builder.toString(); |
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 really don't need StringBuilder
.
The compiler converts simple string concatenation to that one.
public IntegrationFlow fromFile() { | ||
return IntegrationFlows.from(Files.inboundAdapter(new File("/tmp/in")) | ||
.patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000))) | ||
.enrichHeaders(h -> h.header(MessageHeaders.ERROR_CHANNEL, "tfrErrors.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.
https://jira.spring.io/browse/INT-4113.
I mean add comment here.
Although I think after getComponentsToRegister()
for the PollerSpec
we can provide some out-of-the-box workaround just with errorChannel(MessageChannelString)
But right: that is a different story...
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 don't want to pollute the code here with a TODO: will add a comment to the JIRA.
.enrichHeaders(Mail.headers() | ||
.subject("File successfully split and transferred") | ||
.from("foo@bar") | ||
.toFunction(m -> new String[] {"bar@baz"})) |
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.
Yep! These are up to @ConfigurationProperties
. Our own custom one.
I mean for the real mail server tests.
But I see we have so many of options to expose...
Maybe we can live without that for now...
f203bbc
to
2c1f5c9
Compare
@Bean | ||
public IntegrationFlow lines() { | ||
return f -> f.enrichHeaders(h -> h.headerExpression( | ||
FileHeaders.FILENAME, "payload.substring(1, 4) + '.txt'", 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.
WDYT, if we change this .enrichHeaders()
just to the .fileNameExpression("payload.substring(1, 4) + '.txt'")
?
Although it doesn't work with your test somehow... But I see in debug the proper expression and expected file name result.
|
||
// first trigger file flushes | ||
.subscribe(sf -> sf.transform("'/tmp/out/.*\\.txt'", e -> e.id("toTriggerPattern")) | ||
.handle("fileOut.handler", "trigger", e -> e.id("flusher"))) |
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.
Having the problem with bean definitions order on Linux we should move Files.outboundAdapter()
to the separate @Bean
. At least until the fix for https://github.com/spring-projects/spring-integration-java-dsl/issues/119
@Bean | ||
public IntegrationFlow lines() { | ||
return f -> f.enrichHeaders(h -> h.headerExpression( | ||
FileHeaders.FILENAME, "payload.substring(1, 4) + '.txt'", 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.
Gary, any ideas why it doesn't work with just .fileNameExpression()
and I'll merge with the fix for handler bean access.
Thanks
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 will look.
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.
It worked fine for me with the file name expression. I've built on linux too. Let's see what our friend Travis thinks.
Merged as 2c1a070. See my polishing to the tests according Windows compatibility. |
JIRA: https://jira.spring.io/browse/INTSAMPLES-149