Java Outbound Adaptor processing
up vote
0
down vote
favorite
I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
In the configuration class I added the below:
public IntegrationFlow ftpOutboundFlow(Branch myBranch){
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
.useTemporaryFileName(true)
.remoteFileSeparator("/")
//.fileNameExpression("BEY/FEFOexportBEY.csv")
.remoteDirectory(myBranch.getFolderPath()))
.get();
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = OUTBOUND_CHANNEL)
void sendToFtp(File file);
}
@Bean
public IntegrationFlow ftpOutboundChannel() {
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.transform(p -> {
LOG.info("Outbound intermediate Channel, message=rename file:" + p);
return p;
})
.channel(new NullChannel())
.get();
}
And in the Controller class
@RequestMapping("/branch/showbranch/{id}")
public String getBranch (@PathVariable String id, Model model){
model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
addFlowftp(id);
addFlowftpOutbound(id);
return "/branch/showbranch";
}
private void addFlowftpOutbound(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
//this.flowContext.registration(flow).id(name).register();
}
When I run the app and add a new branch with name BEY for example it does not send the file to the FTP server, not sure if I'm doing anything wrong here or if I have the methods written incorrectly.
Here is what I get in the consol
BEY
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : Adding {transformer} as a subscriber to the '94.channel#0' channel
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.integration.channel.DirectChannel : Channel 'application.94.channel#0' has 1 subscriber(s).
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : started 94.org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2018-11-19 15:07:11.631 INFO 7212 --- [nio-8081-exec-6] o.s.i.e.SourcePollingChannelAdapter : started stockInboundPoller
BEY
2018-11-19 15:07:11.640 INFO 7212 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockInboundFlowFromAFT, message=incoming file: BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockIntermediateStageChannel, message=rename file: BEYFEFOexportBEY.csv
spring spring-integration
add a comment |
up vote
0
down vote
favorite
I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
In the configuration class I added the below:
public IntegrationFlow ftpOutboundFlow(Branch myBranch){
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
.useTemporaryFileName(true)
.remoteFileSeparator("/")
//.fileNameExpression("BEY/FEFOexportBEY.csv")
.remoteDirectory(myBranch.getFolderPath()))
.get();
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = OUTBOUND_CHANNEL)
void sendToFtp(File file);
}
@Bean
public IntegrationFlow ftpOutboundChannel() {
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.transform(p -> {
LOG.info("Outbound intermediate Channel, message=rename file:" + p);
return p;
})
.channel(new NullChannel())
.get();
}
And in the Controller class
@RequestMapping("/branch/showbranch/{id}")
public String getBranch (@PathVariable String id, Model model){
model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
addFlowftp(id);
addFlowftpOutbound(id);
return "/branch/showbranch";
}
private void addFlowftpOutbound(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
//this.flowContext.registration(flow).id(name).register();
}
When I run the app and add a new branch with name BEY for example it does not send the file to the FTP server, not sure if I'm doing anything wrong here or if I have the methods written incorrectly.
Here is what I get in the consol
BEY
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : Adding {transformer} as a subscriber to the '94.channel#0' channel
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.integration.channel.DirectChannel : Channel 'application.94.channel#0' has 1 subscriber(s).
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : started 94.org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2018-11-19 15:07:11.631 INFO 7212 --- [nio-8081-exec-6] o.s.i.e.SourcePollingChannelAdapter : started stockInboundPoller
BEY
2018-11-19 15:07:11.640 INFO 7212 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockInboundFlowFromAFT, message=incoming file: BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockIntermediateStageChannel, message=rename file: BEYFEFOexportBEY.csv
spring spring-integration
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
In the configuration class I added the below:
public IntegrationFlow ftpOutboundFlow(Branch myBranch){
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
.useTemporaryFileName(true)
.remoteFileSeparator("/")
//.fileNameExpression("BEY/FEFOexportBEY.csv")
.remoteDirectory(myBranch.getFolderPath()))
.get();
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = OUTBOUND_CHANNEL)
void sendToFtp(File file);
}
@Bean
public IntegrationFlow ftpOutboundChannel() {
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.transform(p -> {
LOG.info("Outbound intermediate Channel, message=rename file:" + p);
return p;
})
.channel(new NullChannel())
.get();
}
And in the Controller class
@RequestMapping("/branch/showbranch/{id}")
public String getBranch (@PathVariable String id, Model model){
model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
addFlowftp(id);
addFlowftpOutbound(id);
return "/branch/showbranch";
}
private void addFlowftpOutbound(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
//this.flowContext.registration(flow).id(name).register();
}
When I run the app and add a new branch with name BEY for example it does not send the file to the FTP server, not sure if I'm doing anything wrong here or if I have the methods written incorrectly.
Here is what I get in the consol
BEY
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : Adding {transformer} as a subscriber to the '94.channel#0' channel
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.integration.channel.DirectChannel : Channel 'application.94.channel#0' has 1 subscriber(s).
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : started 94.org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2018-11-19 15:07:11.631 INFO 7212 --- [nio-8081-exec-6] o.s.i.e.SourcePollingChannelAdapter : started stockInboundPoller
BEY
2018-11-19 15:07:11.640 INFO 7212 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockInboundFlowFromAFT, message=incoming file: BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockIntermediateStageChannel, message=rename file: BEYFEFOexportBEY.csv
spring spring-integration
I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
In the configuration class I added the below:
public IntegrationFlow ftpOutboundFlow(Branch myBranch){
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
.useTemporaryFileName(true)
.remoteFileSeparator("/")
//.fileNameExpression("BEY/FEFOexportBEY.csv")
.remoteDirectory(myBranch.getFolderPath()))
.get();
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = OUTBOUND_CHANNEL)
void sendToFtp(File file);
}
@Bean
public IntegrationFlow ftpOutboundChannel() {
return IntegrationFlows.from(OUTBOUND_CHANNEL)
.transform(p -> {
LOG.info("Outbound intermediate Channel, message=rename file:" + p);
return p;
})
.channel(new NullChannel())
.get();
}
And in the Controller class
@RequestMapping("/branch/showbranch/{id}")
public String getBranch (@PathVariable String id, Model model){
model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
addFlowftp(id);
addFlowftpOutbound(id);
return "/branch/showbranch";
}
private void addFlowftpOutbound(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
//this.flowContext.registration(flow).id(name).register();
}
When I run the app and add a new branch with name BEY for example it does not send the file to the FTP server, not sure if I'm doing anything wrong here or if I have the methods written incorrectly.
Here is what I get in the consol
BEY
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : Adding {transformer} as a subscriber to the '94.channel#0' channel
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.integration.channel.DirectChannel : Channel 'application.94.channel#0' has 1 subscriber(s).
2018-11-19 15:07:11.621 INFO 7212 --- [nio-8081-exec-6] o.s.i.endpoint.EventDrivenConsumer : started 94.org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2018-11-19 15:07:11.631 INFO 7212 --- [nio-8081-exec-6] o.s.i.e.SourcePollingChannelAdapter : started stockInboundPoller
BEY
2018-11-19 15:07:11.640 INFO 7212 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockInboundFlowFromAFT, message=incoming file: BEYFEFOexportBEY.csv
2018-11-19 15:07:11.642 INFO 7212 --- [ask-scheduler-1] f.s.s.configuration.FTIntegration : flow=stockIntermediateStageChannel, message=rename file: BEYFEFOexportBEY.csv
spring spring-integration
spring spring-integration
edited 36 mins ago
asked 5 hours ago
Elias Khattar
116
116
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370579%2fjava-outbound-adaptor-processing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown