私は現在、Spring Integrationを初めて使用しています。
基本的に、Java Spring統合DSLと非同期に複数のファイルロケーションにポーリングしようとしています。私は、ファイル名を取得し、ファイル名でいくつかの操作を実行し、最終的にS3にファイルをプッシュする必要があります、私の質問は、ファイルで操作を実行するこれらのタスクは、タスク実行者またはサービスアクティベータハンドラで実行することができます。私はどちらが正しい場所であるかわからない。Spring統合サービスアクティベータハンドラビジネスロジック
@Autowired
private AWSFileManager awsFileManager;
@Bean
public IntegrationFlow inboundChannelFlow(@Value("${file.poller.delay}") long delay,
@Value("${file.poller.messages}") int maxMsgsPerPoll,
TaskExecutor taskExecutor, MessageSource<File> fileSource)
{
return IntegrationFlows.from(fileSource,
c -> c.poller(Pollers.fixedDelay(delay)
.taskExecutor(taskExecutor)
.maxMessagesPerPoll(maxMsgsPerPoll)))
.handle("AWSFileManager", "fileUpload")
.channel(ApplicationConfiguration.inboundChannel)
.get();
}
@Bean
TaskExecutor taskExecutor(@Value("${file.poller.thread.pool.size}") int poolSize) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
//Runnable task1 =() -> {this.methodsamp();};
taskExecutor.setCorePoolSize(poolSize);
//taskExecutor.execute(task1);
return taskExecutor;
}
@Async
public void methodsamp()
{
try
{
awsFileManager.fileUpload();
System.out.println("test");
}
catch(Exception ex)
{
}
ここにサンプルコードを添付しました。
また、これをパラメータとしてfileUploadメソッドに渡す必要があるため、チャンネル内のファイルのファイル名を取得する方法もあります。 お知らせください。
SOスレッドごとにあまりにも多くの質問をしないでください。 –
確かに..それは次回に続くでしょう。ありがとうございました ! – Raven21