티스토리 뷰
- 개요
- 디렉토리에 파일이 생성되는 경우에 감시하는 라이브러리로써 spring-integration을 사용하고 있다.
- 설정 방법은 간단한데 IntegrationFlow를 반환하는 빈을 설정하면 된다.
- 복수개의 디렉토리를 감시하는 경우 아래와 같이 복수개로 설정하면 된다.
-
@Bean public IntegrationFlow integrationFlow1() { return IntegrationFlow .from(Files.inboundAdapter(new File("c:/inbound1")) , e -> e.poller(Pollers.fixedDelay(1000).maxMessagesPerPoll(10))) .handle(message -> System.out.println(message.getPayload())) .get(); } @Bean public IntegrationFlow integrationFlow2() { return IntegrationFlow .from(Files.inboundAdapter(new File("c:/inbound2")) , e -> e.poller(Pollers.fixedDelay(1000).maxMessagesPerPoll(10))) .handle(message -> System.out.println(message.getPayload())) .get(); } @Bean public IntegrationFlow integrationFlow3() { return IntegrationFlow .from(Files.inboundAdapter(new File("c:/inbound3")) , e -> e.poller(Pollers.fixedDelay(1000).maxMessagesPerPoll(10))) .handle(message -> System.out.println(message.getPayload())) .get(); }
- 서버로써 기동할 때는 문제가 없는데, 테스트코드 실행시 IntegrationFlow를 하나로 특정할 수 없다는 아래와 같은 메시지가 나와버린다.
-
Caused by: java.lang.IllegalStateException: Unable to register mock bean org.springframework.integration.dsl.IntegrationFlow expected a single matching bean to replace but found [integrationFlow1, integrationFlow2, integrationFlow3]
- 해결방법
- 아래와 같은 Test용 설정을 만들어서 IntegrationFlow의 Primary를 만든다.
-
import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.integration.dsl.IntegrationFlow; @TestConfiguration public class IntegrationFlowTestConfig { @Primary @Bean public IntegrationFlow noActionIntegrationFlow() { return null; } }
- IntegrationFlow는 감시만 할 뿐, 로직은 별도의 핸들러가 처리하기 때문에 문제가 없을 것으로 보인다.
'IT' 카테고리의 다른 글
opencv를 이용한 QR코드 인식 (0) | 2024.10.11 |
---|---|
com.amazonaws 라이브러리에서 region,credential 설정 방식과 문제점 (1) | 2024.09.06 |
net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder을 이용한 JSON포맷 동적 필드 로그 생성 (0) | 2023.08.14 |
Python AWS Powertools log 날짜포맷 변경하기 (0) | 2023.08.09 |
AWS X-Ray로 실행시간 체크하기 구현(Spring) (0) | 2023.08.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- PostgreSQL #FOR UPDATE #SKIP LOCKED
- AWS #X-Ray
- spring-integration
- Maven LF #메이븐 개행문자
- json
- Postgresql #MultiTruncate
- Python #Powertools
- yaml
- Two Sum
- springintegration #파일감시 #디렉토리감시 #파일완료검사
- reverse integer
- multipleIntegrationFlow
- spring #redis #redis-cluster
- mybatis @insert값 @update값
- SnakeYAML
- QR코드읽기 #ReadQRCode
- excel table
- palindrome number
- cannotResolveSymbol
- leetcode
- 로그테스트 #콘솔로그테스트 #System.out
- opencv로qr코드인식
- add two numbers
- aws #aws region #aws credential #aws region provider #aws credential provier
- lombok #maven build #sym
- 로그파일인덱스
- PostgreSQL #sequnceName
- logback #logstash #LoggingEventCompositeJsonEncoder #로그JSON
- excel to markdown
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함