Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/surefire-plugin.version-3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ictlm5 committed Oct 3, 2023
2 parents 3bc824a + 1e108b2 commit 1826d90
Show file tree
Hide file tree
Showing 36 changed files with 474 additions and 201 deletions.
12 changes: 11 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
"code",
"maintenance"
]
}
},
{
"login": "pjgg",
"name": "pjgg",
"avatar_url": "https://avatars.githubusercontent.com/u/3541131?v=4",
"profile": "https://github.com/pjgg",
"contributions": [
"code",
"maintenance"
]
}
],
"contributorsPerLine": 7,
"projectName": "quarkus-hivemq-client",
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

version: 2
updates:
# Maintain dependencies for Maven
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "org.apache.maven.plugins:maven-compiler-plugin"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
53 changes: 0 additions & 53 deletions .github/workflows/build.yml

This file was deleted.

106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: "Pull Request CI"

on:
push:
branches:
- "main"
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
- '*.md'
- '*.adoc'
- '*.txt'
- '.all-contributorsrc'
pull_request:
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
- '*.md'
- '*.adoc'
- '*.txt'
- '.all-contributorsrc'

jobs:
validate-format:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
check-latest: true
- name: format
run: mvn -V -B formatter:validate verify -DskipTests -DskipITs
- name: Tar Maven Repo
shell: bash
run: tar -I 'pigz -9' -cf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v3
with:
name: maven-repo
path: maven-repo.tgz
linux-build-jvm:
name: PR - Linux - JVM build - Latest Version
runs-on: ubuntu-latest
timeout-minutes: 20
needs: validate-format
strategy:
matrix:
java: [ 11 ]
steps:
- uses: actions/checkout@v3
- name: Install JDK {{ matrix.java }}
# Uses sha for added security since tags can be updated
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
check-latest: true
cache: 'maven'
- name: Download Maven Repo
uses: actions/download-artifact@v3
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Build with Maven
run: mvn -V -B -am clean verify
# TODO there is an error under investigation on Native mode
# linux-build-native:
# name: PR - Linux - Native build - Latest Version
# runs-on: ubuntu-latest
# timeout-minutes: 60
# needs: validate-format
# strategy:
# matrix:
# java: [ 11 ]
# steps:
# - uses: actions/checkout@v3
# - name: Install JDK {{ matrix.java }}
# # Uses sha for added security since tags can be updated
# uses: actions/setup-java@v3
# with:
# distribution: 'temurin'
# java-version: ${{ matrix.java }}
# check-latest: true
# cache: 'maven'
# - name: Download Maven Repo
# uses: actions/download-artifact@v3
# with:
# name: maven-repo
# path: .
# - name: Extract Maven Repo
# shell: bash
# run: tar -xzf maven-repo.tgz -C ~
# - name: Build with Maven
# run: mvn -V -B -am clean verify -Dnative

94 changes: 94 additions & 0 deletions integration-tests/hivemq-client-smallrye/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.hivemqclient</groupId>
<artifactId>quarkus-hivemq-client-integration-tests</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>

<artifactId>quarkus-hivemq-client-integration-tests-smallrye</artifactId>
<name>Quarkus - Hivemq Client - Integration Tests smallrye</name>

<properties>
<hive.testcontainers.version>1.17.6</hive.testcontainers.version>
<exclude.quarkus.native.tests>**/*Native*IT.java</exclude.quarkus.native.tests>
<include.tests>**/*Test.java</include.tests>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-mqtt</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.hivemqclient</groupId>
<artifactId>quarkus-hivemq-client</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>hivemq</artifactId>
<version>${hive.testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<excludes>
<exclude>${exclude.quarkus.native.tests}</exclude>
</excludes>
<includes>
<include>${include.tests}</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkiverse.hivemqclient.test.smallrye;

import javax.enterprise.context.ApplicationScoped;

import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import org.jboss.logging.Logger;

import io.smallrye.reactive.messaging.annotations.Broadcast;

/**
* A bean consuming data from the "prices" MQTT topic and applying some conversion.
* The result is pushed to the "my-data-stream" stream which is an in-memory stream.
*/
@ApplicationScoped
public class PriceConverter {

private static final Logger LOG = Logger.getLogger(PriceConverter.class);
private static final double CONVERSION_RATE = 0.88;

@Incoming("prices")
@Outgoing("my-data-stream")
@Broadcast
public double process(byte[] priceRaw) {
int priceInUsd = Integer.parseInt(new String(priceRaw));
LOG.infof("Receiving price: %d ", priceInUsd);
return priceInUsd * CONVERSION_RATE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkiverse.hivemqclient.test.smallrye;

import java.time.Duration;
import java.util.Random;

import javax.enterprise.context.ApplicationScoped;

import org.eclipse.microprofile.reactive.messaging.Outgoing;
import org.jboss.logging.Logger;

import io.smallrye.mutiny.Multi;

/**
* A bean producing random prices every second.
* The prices are written to a MQTT topic (prices). The MQTT configuration is specified in the application configuration.
*/
@ApplicationScoped
public class PriceGenerator {

private static final Logger LOG = Logger.getLogger(PriceGenerator.class);

private Random random = new Random();

@Outgoing("topic-price")
public Multi<Integer> generate() {
return Multi.createFrom().ticks().every(Duration.ofSeconds(1))
.onOverflow().drop()
.map(tick -> {
int price = random.nextInt(100);
LOG.infof("Sending price: %d", price);
return price;
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkiverse.hivemqclient.test.smallrye;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.reactive.messaging.Channel;

import io.smallrye.mutiny.Multi;

/**
* A simple resource retrieving the "in-memory" "my-data-stream" and sending the items to a server sent event.
*/
@Path("/prices")
public class PriceResource {

@Inject
@Channel("my-data-stream")
Multi<Double> prices;

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello";
}

@GET
@Path("/stream")
@Produces(MediaType.SERVER_SENT_EVENTS)
public Multi<Double> stream() {
return prices;
}
}
Loading

0 comments on commit 1826d90

Please sign in to comment.