-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from dhis2/INTEROP-37
feat(INTEROP-37): support scenarios in INTEROP-37 and minor refactori…
- Loading branch information
Showing
18 changed files
with
259 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,63 @@ | ||
package org.hisp.hieboot; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.hisp.hieboot.camel.security.SelfSignedHttpClientConfigurer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.util.StreamUtils; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
@SpringBootApplication | ||
public abstract class CamelHieBootApp extends SpringBootServletInitializer { | ||
|
||
protected static final Logger LOGGER = LoggerFactory.getLogger(CamelHieBootApp.class); | ||
|
||
@Value("${server.ssl.enabled:false}") | ||
protected Boolean serverSslEnabled; | ||
|
||
@Value("${server.servlet.context-path:}") | ||
protected String serverServletContextPath; | ||
|
||
@Value("${management.endpoints.web.base-path}") | ||
protected String managementEndpointsWebBasePath; | ||
|
||
@Value("${server.port}") | ||
protected int serverPort; | ||
|
||
@Autowired | ||
protected CamelContext camelContext; | ||
|
||
@Bean | ||
public SelfSignedHttpClientConfigurer selfSignedHttpClientConfigurer() { | ||
return new SelfSignedHttpClientConfigurer(); | ||
} | ||
|
||
@EventListener(ApplicationReadyEvent.class) | ||
public void onApplicationReadyEvent() | ||
throws | ||
IOException { | ||
|
||
String baseUrl = String.format("%s://%s:%s%s", serverSslEnabled ? "https" : "http", | ||
InetAddress.getLocalHost().getHostAddress(), serverPort, serverServletContextPath); | ||
|
||
StringBuilder onlineBanner = new StringBuilder(); | ||
onlineBanner.append("Hawtio console: ").append(baseUrl).append(managementEndpointsWebBasePath) | ||
.append("/hawtio\n"); | ||
|
||
LOGGER.info( | ||
String.format(StreamUtils.copyToString( | ||
Thread.currentThread().getContextClassLoader().getResourceAsStream("online-banner.txt"), | ||
StandardCharsets.UTF_8), | ||
onlineBanner)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,6 @@ public Message getMessage() { | |
|
||
@Override | ||
public String getContext() { | ||
return ""; | ||
return context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/hisp/hieboot/camel/processor/replay/FailCheckpointProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.hisp.hieboot.camel.processor.replay; | ||
|
||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Processor; | ||
import org.hisp.hieboot.camel.HieExchange; | ||
import org.hisp.hieboot.camel.spi.MessageRepository; | ||
import org.hisp.hieboot.camel.spi.RepositoryMessage; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.List; | ||
|
||
public class FailCheckpointProcessor implements Processor { | ||
|
||
protected static final Logger LOGGER = LoggerFactory.getLogger(FailCheckpointProcessor.class); | ||
|
||
@Autowired | ||
private MessageRepository messageRepository; | ||
|
||
@Override | ||
public void process(Exchange exchange) throws Exception { | ||
List<RepositoryMessage> repositoryMessages = messageRepository.retrieve(String.format("processing:%s:%s:*", exchange.getProperty(HieExchange.REPLAY_CHECKPOINT_MESSAGE_ID), exchange.getProperty(HieExchange.REPLAY_CHECKPOINT_ROUTE_ID))); | ||
if (!repositoryMessages.isEmpty()) { | ||
RepositoryMessage repositoryMessage = repositoryMessages.get(0); | ||
messageRepository.store(repositoryMessage.getKey().replace("processing:", "failed:"), repositoryMessage.getMessage(), exchange.getMessage().getHeader("errorMessage", String.class)); | ||
messageRepository.delete(repositoryMessage.getKey()); | ||
LOGGER.info("Failed replay checkpoint for message [{}] in route [{}]", exchange.getProperty(HieExchange.REPLAY_CHECKPOINT_MESSAGE_ID), exchange.getUnitOfWork().getRoute().getRouteId()); | ||
} | ||
} | ||
|
||
public MessageRepository getMessageRepository() { | ||
return messageRepository; | ||
} | ||
|
||
public void setMessageRepository(MessageRepository messageRepository) { | ||
this.messageRepository = messageRepository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
Powered By | ||
____ _ _ _ ___ _____ ____ _ | ||
/ ___|__ _ _ __ ___ ___| | | | | |_ _| ____| | __ ) ___ ___ | |_ | ||
| | / _` | '_ ` _ \ / _ \ | | |_| || || _| | _ \ / _ \ / _ \| __| | ||
| |__| (_| | | | | | | __/ | | _ || || |___ | |_) | (_) | (_) | |_ | ||
\____\__,_|_| |_| |_|\___|_| |_| |_|___|_____| |____/ \___/ \___/ \__| | ||
|
||
Camel HIE Boot version: v${project.version} | ||
Apache Camel version: ${camel.version} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...hie-replay-checkpoint-action.kamelet.yaml → ...ate-replay-checkpoint-action.kamelet.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/resources/kamelets/hie-fail-replay-checkpoint-action.kamelet.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: camel.apache.org/v1 | ||
kind: Kamelet | ||
metadata: | ||
name: hie-fail-replay-checkpoint-action | ||
annotations: | ||
camel.apache.org/kamelet.support.level: Stable | ||
camel.apache.org/provider: HISP Centre | ||
camel.apache.org/kamelet.group: HIE Replay | ||
camel.apache.org/kamelet.namespace: HIE | ||
labels: | ||
camel.apache.org/kamelet.type: action | ||
spec: | ||
definition: | ||
title: Fail Replay Checkpoint Action | ||
description: |- | ||
Marks replay checkpoint as failed. | ||
properties: | ||
replayChannelName: | ||
title: Replay Channel Name | ||
type: string | ||
default: replay-{{routeId}} | ||
dataTypes: | ||
in: | ||
headers: | ||
errorMessage: | ||
title: Error Message | ||
type: string | ||
template: | ||
beans: | ||
- name: failCheckpointProcessor | ||
type: "#class:org.hisp.hieboot.camel.processor.replay.FailCheckpointProcessor" | ||
route: | ||
from: | ||
uri: kamelet:source | ||
steps: | ||
- process: | ||
ref: "{{failCheckpointProcessor}}" | ||
- to: kamelet:sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
Camel HIE Boot is up and running... | ||
|
||
%s | ||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.