Skip to content
Snippets Groups Projects
Commit efcd05f7 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3665 implement runner to fetch message on startup

parent 4c657479
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,18 @@ ...@@ -76,6 +76,18 @@
<!-- <artifactId>jaxws-impl</artifactId>--> <!-- <artifactId>jaxws-impl</artifactId>-->
<!-- <version>2.3.1</version>--> <!-- <version>2.3.1</version>-->
<!--</dependency>--> <!--</dependency>-->
<!-- Dev -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package de.ozgcloud.eingang.xta; package de.ozgcloud.eingang.xta;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import de.itvsh.kop.eingangsadapter.common.formdata.FormData; import de.itvsh.kop.eingangsadapter.common.formdata.FormData;
...@@ -14,15 +16,24 @@ import lombok.extern.log4j.Log4j2; ...@@ -14,15 +16,24 @@ import lombok.extern.log4j.Log4j2;
@Log4j2 @Log4j2
@Component @Component
@Profile("!itcase") @Profile("!itcase")
@ConditionalOnProperty(havingValue = "ozgcloud.xta.scheduler.enabled") class XtaRunner implements ApplicationListener<ContextRefreshedEvent> {
class XtaScheduler {
@Autowired @Autowired
private XtaService service; private XtaService service;
@Autowired @Autowired
private SemantikAdapter semantikAdapter; private SemantikAdapter semantikAdapter;
@Scheduled(initialDelayString = "${ozgcloud.xta.scheduler.initialDelay:5000}", fixedDelayString = "${ozgcloud.xta.scheduler.fixedDelay:900000") @Autowired
private ApplicationContext context;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
LOG.info("Fetching XTA Messages");
runGetXtaMessages();
SpringApplication.exit(context, () -> 0);
}
void runGetXtaMessages() { void runGetXtaMessages() {
service.getMessagesAsFormData().forEach(this::processAndAcknowledge); service.getMessagesAsFormData().forEach(this::processAndAcknowledge);
} }
...@@ -35,4 +46,5 @@ class XtaScheduler { ...@@ -35,4 +46,5 @@ class XtaScheduler {
LOG.error("Error on processing XTA-Message. Continue with next message.", e); LOG.error("Error on processing XTA-Message. Continue with next message.", e);
} }
} }
} }
...@@ -26,7 +26,7 @@ class XtaRunnerTest { ...@@ -26,7 +26,7 @@ class XtaRunnerTest {
@Nested @Nested
class TestRunGetXtaMessages { class TestRunGetXtaMessages {
private FormData formData;// = FormDataTestFactory.create(); private FormData formData = FormDataTestFactory.create();
@BeforeEach @BeforeEach
void init() { void init() {
...@@ -51,7 +51,7 @@ class XtaRunnerTest { ...@@ -51,7 +51,7 @@ class XtaRunnerTest {
void shouldAcknowledgeReceive() { void shouldAcknowledgeReceive() {
scheduler.runGetXtaMessages(); scheduler.runGetXtaMessages();
// verify(service).acknowledgeReceive(XtaMessageTestFactory.MESSAGE_ID); verify(service).acknowledgeReceive(XtaMessageTestFactory.MESSAGE_ID);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment