How to configure the Spring Cloud to use Kubernetes or OpenShift
First of all, install minishift or minikube
Follow this steps:
FROM rabbitmq:management | |
RUN rabbitmq-plugins enable --offline rabbitmq_mqtt | |
EXPOSE 15671 15672 1883 |
mosquitto_pub -t /sensor -m "{"id":"1", "tenantId":"1", "token":"123", "timestamp":$(date +"%s000"), "temperature":10.0}" -u guest -P guest |
package com.iot.edge.config; | |
import org.springframework.cloud.stream.annotation.EnableBinding; | |
import org.springframework.cloud.stream.messaging.Processor; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
@EnableBinding(Processor.class) | |
public class StreamConfig { | |
} |
package com.iot.edge.consumer; | |
import com.iot.edge.service.AssetService; | |
import com.iot.edge.dto.SensorData; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.cloud.stream.annotation.StreamListener; | |
import org.springframework.cloud.stream.messaging.Processor; | |
import org.springframework.messaging.support.MessageBuilder; | |
import org.springframework.stereotype.Component; |
spring: | |
cloud: | |
stream: | |
bindings: | |
input: | |
destination: amq.topic | |
binder: rabbitmqtt | |
group: sensor-consumer-group | |
output: | |
destination: iot.edge.topic |
package com.iot.edge.dto; | |
import com.fasterxml.jackson.annotation.JsonAnyGetter; | |
import com.fasterxml.jackson.annotation.JsonAnySetter; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import com.fasterxml.jackson.annotation.JsonInclude; | |
import java.util.HashMap; | |
import java.util.Map; |
spring: | |
cloud: | |
stream: | |
bindings: | |
topic1: | |
destination: topic1 | |
contentType: application/json | |
group: process | |
binder: eventhub1 | |
consumer: |