updated for native
This commit is contained in:
parent
2628a7506f
commit
1908c4d7d1
4 changed files with 33 additions and 11 deletions
2
pom.xml
2
pom.xml
|
|
@ -134,7 +134,7 @@
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<skipITs>false</skipITs>
|
<skipITs>false</skipITs>
|
||||||
<quarkus.package.type>uber-jar</quarkus.package.type>
|
<quarkus.package.type>native</quarkus.package.type>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,26 @@
|
||||||
package com.c4181.camel;
|
package com.c4181.camel;
|
||||||
|
|
||||||
|
import com.c4181.properties.AppProperties;
|
||||||
import org.apache.camel.Exchange;
|
import org.apache.camel.Exchange;
|
||||||
import org.apache.camel.builder.RouteBuilder;
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.measure.Measure;
|
import javax.measure.Measure;
|
||||||
import javax.measure.quantity.Pressure;
|
import javax.measure.quantity.Pressure;
|
||||||
import javax.measure.unit.NonSI;
|
import javax.measure.unit.NonSI;
|
||||||
import javax.measure.unit.Unit;
|
import javax.measure.unit.Unit;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
public class CamelConfiguration extends RouteBuilder {
|
public class CamelConfiguration extends RouteBuilder {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AppProperties appProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure() {
|
public void configure() {
|
||||||
from("paho-mqtt5:teslamate/cars/1/update_version?brokerUrl={{sys:BROKER_URL}}")
|
from("paho-mqtt5:teslamate/cars/1/update_version?brokerUrl=" + appProperties.brokerUrl())
|
||||||
.filter(exchange -> StringUtils.isNotBlank(exchange.getIn().getBody(String.class)))
|
.filter(exchange -> StringUtils.isNotBlank(exchange.getIn().getBody(String.class)))
|
||||||
.process((exchange -> {
|
.process((exchange -> {
|
||||||
String updateVersion = exchange.getIn().getBody(String.class);
|
String updateVersion = exchange.getIn().getBody(String.class);
|
||||||
|
|
@ -26,27 +33,27 @@ public class CamelConfiguration extends RouteBuilder {
|
||||||
|
|
||||||
log.info("New Version {} found. Sending to telegram", updateVersion);
|
log.info("New Version {} found. Sending to telegram", updateVersion);
|
||||||
}))
|
}))
|
||||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
.to(appProperties.telegramRoute());
|
||||||
|
|
||||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fl?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Front left")))
|
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fl?brokerUrl=" + appProperties.brokerUrl()).process((exchange -> checkTirePressure(exchange, "Front left")))
|
||||||
.throttle(1).rejectExecution(true)
|
.throttle(1).rejectExecution(true)
|
||||||
.timePeriodMillis(900000) // 15 minutes
|
.timePeriodMillis(900000) // 15 minutes
|
||||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
.to(appProperties.telegramRoute());
|
||||||
|
|
||||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fr?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Front right")))
|
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fr?brokerUrl=" + appProperties.brokerUrl()).process((exchange -> checkTirePressure(exchange, "Front right")))
|
||||||
.throttle(1).rejectExecution(true)
|
.throttle(1).rejectExecution(true)
|
||||||
.timePeriodMillis(900000) // 15 minutes
|
.timePeriodMillis(900000) // 15 minutes
|
||||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
.to(appProperties.telegramRoute());
|
||||||
|
|
||||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rl?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Back left")))
|
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rl?brokerUrl=" + appProperties.brokerUrl()).process((exchange -> checkTirePressure(exchange, "Back left")))
|
||||||
.throttle(1).rejectExecution(true)
|
.throttle(1).rejectExecution(true)
|
||||||
.timePeriodMillis(900000) // 15 minutes
|
.timePeriodMillis(900000) // 15 minutes
|
||||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
.to(appProperties.telegramRoute());
|
||||||
|
|
||||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rr?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Back right")))
|
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rr?brokerUrl=" + appProperties.brokerUrl()).process((exchange -> checkTirePressure(exchange, "Back right")))
|
||||||
.throttle(1).rejectExecution(true)
|
.throttle(1).rejectExecution(true)
|
||||||
.timePeriodMillis(900000) // 15 minutes
|
.timePeriodMillis(900000) // 15 minutes
|
||||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
.to(appProperties.telegramRoute());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTirePressure(Exchange exchange, String tire) {
|
private void checkTirePressure(Exchange exchange, String tire) {
|
||||||
|
|
|
||||||
10
src/main/java/com/c4181/properties/AppProperties.java
Normal file
10
src/main/java/com/c4181/properties/AppProperties.java
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.c4181.properties;
|
||||||
|
|
||||||
|
import io.smallrye.config.ConfigMapping;
|
||||||
|
|
||||||
|
@ConfigMapping(prefix = "app")
|
||||||
|
public interface AppProperties {
|
||||||
|
|
||||||
|
String brokerUrl();
|
||||||
|
String telegramRoute();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
app.broker-url=${BROKER_URL}
|
||||||
|
app.telegram-route=telegram:bots?authorizationToken=${TELEGRAM_BOT_ID}&chatId=${CHAT_ID}
|
||||||
|
|
||||||
|
TELEGRAM_BOT_ID=${TELEGRAM_BOT_ID}
|
||||||
|
CHAT_ID=${CHAT_ID}
|
||||||
Loading…
Reference in a new issue