This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
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 #61 from patientsknowbest/feature/pubsub-routes
Feature/pubsub routes
- Loading branch information
Showing
8 changed files
with
136 additions
and
10 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
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,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>pkb-common</artifactId> | ||
<groupId>com.pkb.pkbcommon</groupId> | ||
<version>${revision}${changelist}</version> | ||
</parent> | ||
|
||
<artifactId>pubsub</artifactId> | ||
<name>pkb-common/pubsub</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-google-pubsub</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.avro</groupId> | ||
<artifactId>avro</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.avro</groupId> | ||
<artifactId>avro-maven-plugin</artifactId> | ||
<version>${avro.version}</version> | ||
<configuration> | ||
<stringType>String</stringType> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>schema</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory> | ||
<outputDirectory>${project.basedir}/target/generated-sources/main/java/</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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,12 @@ | ||
{ | ||
"namespace": "com.pkb.common.pubsub.payload", | ||
"type": "record", | ||
"name": "QuestionnaireCompletedMessage", | ||
"fields": [ | ||
{"name": "patientId", "type": "string"}, | ||
{"name": "questionnaireId", "type": "string"}, | ||
{"name": "questionnaireResponseId", "type": "string"}, | ||
{"name": "questionnaireName", "type": "string"}, | ||
{"name": "sourceCluster", "type": "string"} | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
pubsub/src/main/java/com/pkb/common/pubsub/QuestionnaireCompletedRoute.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,26 @@ | ||
package com.pkb.common.pubsub; | ||
|
||
import com.pkb.common.pubsub.config.IGeneralPubsubConfig; | ||
import org.apache.camel.Endpoint; | ||
import org.apache.camel.EndpointInject; | ||
import org.apache.camel.builder.RouteBuilder; | ||
|
||
public abstract class QuestionnaireCompletedRoute extends RouteBuilder { | ||
|
||
@EndpointInject(property = "questionnaireEventTopicUri") | ||
private Endpoint questionnaireEventTopic; | ||
|
||
public abstract IGeneralPubsubConfig config(); | ||
|
||
public String getQuestionnaireEventTopicUri() { | ||
return String.format("google-pubsub:%s:questionnaire_event_topic", config().getProject()); | ||
} | ||
|
||
@Override | ||
public void configure() { | ||
from("direct:questionnaire_event_topic") | ||
.to(questionnaireEventTopic); | ||
} | ||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
pubsub/src/main/java/com/pkb/common/pubsub/config/GeneralPubsubConfig.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,16 @@ | ||
package com.pkb.common.pubsub.config; | ||
|
||
public class GeneralPubsubConfig implements IGeneralPubsubConfig { | ||
|
||
private final String project; | ||
|
||
public GeneralPubsubConfig(String project) { | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
public String getProject() { | ||
return project; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
pubsub/src/main/java/com/pkb/common/pubsub/config/IGeneralPubsubConfig.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,7 @@ | ||
package com.pkb.common.pubsub.config; | ||
|
||
public interface IGeneralPubsubConfig { | ||
|
||
String getProject(); | ||
|
||
} |
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