Loading .gitignore 0 → 100644 +4 −0 Original line number Diff line number Diff line .* !.gitignore !.gitlab-ci.yml target .gitlab-ci.yml 0 → 100644 +24 −0 Original line number Diff line number Diff line stages: - build maven-build: stage: build image: redmic/maven-gitlab variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" only: - branches cache: paths: - .m2/repository/ script: - mvn deploy -B - "COVERAGE=$(xmllint --html --xpath '//table[@id=\"coveragetable\"]/tfoot//td[@class=\"ctr2\"][1]/text()' target/site/jacoco/index.html)" - 'echo "Coverage: $COVERAGE"' after_script: - rm -r .m2/repository/es artifacts: name: "$CI_PROJECT_NAME" expire_in: '6 months' paths: - target/*.jar README.md 0 → 100644 +4 −0 Original line number Diff line number Diff line [](https://git.redmic.net/redmic-server/broker-lib/commits/dev) [](https://git.redmic.net/redmic-server/broker-lib/commits/dev) Librería para trabajar con el broker No newline at end of file pom.xml 0 → 100644 +169 −0 Original line number Diff line number Diff line <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"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath/> </parent> <modelVersion>4.0.0</modelVersion> <groupId>es.redmic.lib</groupId> <artifactId>broker-lib</artifactId> <packaging>jar</packaging> <version>0.6.0</version> <name>broker-lib</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <java.version>1.8</java.version> <!-- REDMIC --> <redmic.jackson-jsonschema.version>0.6.0</redmic.jackson-jsonschema.version> <!-- OTHERS --> <avro.version>1.8.2</avro.version> <confluent.version>4.0.0</confluent.version> <hibernate-validator.version>6.0.8.Final</hibernate-validator.version> <!-- Version plugins --> <jacoco.version>0.8.1</jacoco.version> <!-- Environment variables --> <env.MAVEN_REPO_URL>https://artifactory.redmic.net/artifactory</env.MAVEN_REPO_URL> </properties> <dependencies> <dependency> <groupId>es.redmic.lib</groupId> <artifactId>jackson-jsonschema</artifactId> <version>${redmic.jackson-jsonschema.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>common-config</artifactId> <version>${confluent.version}</version> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>kafka-schema-registry-client</artifactId> <version>${confluent.version}</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>kafka-avro-serializer</artifactId> <version>${confluent.version}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.avro</groupId> <artifactId>avro</artifactId> <version>${avro.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate-validator.version}</version> </dependency> <!-- Logs --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <scope>provided</scope> </dependency> <!-- Test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <distributionManagement> <repository> <id>central</id> <name>redmic-releases</name> <url>${env.MAVEN_REPO_URL}/libs-release-local</url> </repository> <snapshotRepository> <id>snapshots</id> <name>redmic-snapshots</name> <url>${env.MAVEN_REPO_URL}/libs-snapshot-local</url> <uniqueVersion>false</uniqueVersion> </snapshotRepository> </distributionManagement> <build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> src/main/java/es/redmic/brokerlib/alert/AlertService.java 0 → 100644 +36 −0 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; @Service public class AlertService { private static Logger logger = LogManager.getLogger(); @Value("${broker.topic.alert}") private String ALERT_TOPIC; @Value("${alert.email}") private String ALERT_EMAIL; @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void errorAlert(String subject, String message) { String subjectDefault = "[ERROR] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); } private void send(Message message) { logger.info("sending alert='{}' to topic='{}'", message, ALERT_TOPIC); kafkaTemplate.send(ALERT_TOPIC, message); } } Loading
.gitignore 0 → 100644 +4 −0 Original line number Diff line number Diff line .* !.gitignore !.gitlab-ci.yml target
.gitlab-ci.yml 0 → 100644 +24 −0 Original line number Diff line number Diff line stages: - build maven-build: stage: build image: redmic/maven-gitlab variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" only: - branches cache: paths: - .m2/repository/ script: - mvn deploy -B - "COVERAGE=$(xmllint --html --xpath '//table[@id=\"coveragetable\"]/tfoot//td[@class=\"ctr2\"][1]/text()' target/site/jacoco/index.html)" - 'echo "Coverage: $COVERAGE"' after_script: - rm -r .m2/repository/es artifacts: name: "$CI_PROJECT_NAME" expire_in: '6 months' paths: - target/*.jar
README.md 0 → 100644 +4 −0 Original line number Diff line number Diff line [](https://git.redmic.net/redmic-server/broker-lib/commits/dev) [](https://git.redmic.net/redmic-server/broker-lib/commits/dev) Librería para trabajar con el broker No newline at end of file
pom.xml 0 → 100644 +169 −0 Original line number Diff line number Diff line <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"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath/> </parent> <modelVersion>4.0.0</modelVersion> <groupId>es.redmic.lib</groupId> <artifactId>broker-lib</artifactId> <packaging>jar</packaging> <version>0.6.0</version> <name>broker-lib</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <java.version>1.8</java.version> <!-- REDMIC --> <redmic.jackson-jsonschema.version>0.6.0</redmic.jackson-jsonschema.version> <!-- OTHERS --> <avro.version>1.8.2</avro.version> <confluent.version>4.0.0</confluent.version> <hibernate-validator.version>6.0.8.Final</hibernate-validator.version> <!-- Version plugins --> <jacoco.version>0.8.1</jacoco.version> <!-- Environment variables --> <env.MAVEN_REPO_URL>https://artifactory.redmic.net/artifactory</env.MAVEN_REPO_URL> </properties> <dependencies> <dependency> <groupId>es.redmic.lib</groupId> <artifactId>jackson-jsonschema</artifactId> <version>${redmic.jackson-jsonschema.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>common-config</artifactId> <version>${confluent.version}</version> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>kafka-schema-registry-client</artifactId> <version>${confluent.version}</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.confluent</groupId> <artifactId>kafka-avro-serializer</artifactId> <version>${confluent.version}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.avro</groupId> <artifactId>avro</artifactId> <version>${avro.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate-validator.version}</version> </dependency> <!-- Logs --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <scope>provided</scope> </dependency> <!-- Test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <distributionManagement> <repository> <id>central</id> <name>redmic-releases</name> <url>${env.MAVEN_REPO_URL}/libs-release-local</url> </repository> <snapshotRepository> <id>snapshots</id> <name>redmic-snapshots</name> <url>${env.MAVEN_REPO_URL}/libs-snapshot-local</url> <uniqueVersion>false</uniqueVersion> </snapshotRepository> </distributionManagement> <build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
src/main/java/es/redmic/brokerlib/alert/AlertService.java 0 → 100644 +36 −0 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; @Service public class AlertService { private static Logger logger = LogManager.getLogger(); @Value("${broker.topic.alert}") private String ALERT_TOPIC; @Value("${alert.email}") private String ALERT_EMAIL; @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void errorAlert(String subject, String message) { String subjectDefault = "[ERROR] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); } private void send(Message message) { logger.info("sending alert='{}' to topic='{}'", message, ALERT_TOPIC); kafkaTemplate.send(ALERT_TOPIC, message); } }