I am still fighting to realize the following flow using Spring Integration 5.5:
- read a file from remote SFTP service as InputStream
- transform that stream into a custom entity
- persist the entity via JPA
- delete remote file from SFTP server
So, I have the following flow using Java DSL:
@Configuration
public class Flow {
@Bean
public StandardIntegrationFlow createFlow() {
return IntegrationFlows
.from(source())
.publishSubscribeChannel(pubSub -> pubSub
.subscribe(sub1 -> sub1
.transform(Message.class, this::transform)
.handle(persist(), e -> e.transactional(false))
)
.subscribe(sub2 -> sub2
.handle(remove())
)
)
.get();
}
public MessageSource<InputStream> source() {
return null;
}
public Message<MyEntity> transform(Message<InputStream> message) {
return null;
}
public JpaOutboundGateway persist() {
return null;
}
public AbstractMessageHandler remove() {
return null;
}
}
My IDE (VSCode) is giving me no warning about this code, however when trying to compile it using Apache Maven 3.8 / JDK 17, I get the following compilation error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project amqp: Compilation failure
[ERROR] /C:/Users/.../src/main/java/com/example/Flow.java:[25,46] cannot find symbol
[ERROR] symbol: method transactional(boolean)
[ERROR] location: variable e of type java.lang.Object
The reason seems to the the transformation (transform()
), because as soon as I remove that transformation, the code compiles. Of course it fails during runtime, because persist()
method expects a Message, not Message.
Any ideas on what is wrong with my transform-methods signature?
CodePudding user response:
Confirmed. Looks like some bug in Java compiler by itself.
When I swap those transform()
and handle()
it compiles.
Or if I remove it or modify some other way...
You can use this as a workaround for now:
.transform(this, "transform")
That compiler error is fully not relevant to your transform()
definition.
I might be mistaken judging Java compiler, so will be glad to see some other explanations and hints what is wrong with our code.