Skip to content

Instantly share code, notes, and snippets.

@rfaita
rfaita / SpringCloudK8S.md
Created May 14, 2019 13:23
How to configure Spring Cloud to use Kubernetes/OpenShift

Kubernetes/OpenShift

How to configure the Spring Cloud to use Kubernetes or OpenShift

First of all, install minishift or minikube

Follow this steps:

  • Project configutaion

@rfaita
rfaita / wsl2.md
Last active October 1, 2023 04:03
Installing WSL2 on Windows 10

Install and configure WSL2 on windows 10

Install WSL2

Using the following link here install the WSL 2 on your windows 10.

Install X-Server

VcXsrv seems to the best choice for X-Server in Windows

@rfaita
rfaita / Dockerfile
Last active July 23, 2020 18:12
How to configure RabbitMQ MQTT plugin
FROM rabbitmq:management
RUN rabbitmq-plugins enable --offline rabbitmq_mqtt
EXPOSE 15671 15672 1883
@rfaita
rfaita / send.sh
Created July 23, 2020 18:36
mosquitto_pub
mosquitto_pub -t /sensor -m "{"id":"1", "tenantId":"1", "token":"123", "timestamp":$(date +"%s000"), "temperature":10.0}" -u guest -P guest
@rfaita
rfaita / StreamConfig.java
Created July 23, 2020 19:11
StreamConfig
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 {
}
@rfaita
rfaita / EdgeConsumer.java
Created July 23, 2020 19:13
EdgeConsumer
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;
@rfaita
rfaita / application.yml
Last active July 23, 2020 19:31
application.yml
spring:
cloud:
stream:
bindings:
input:
destination: amq.topic
binder: rabbitmqtt
group: sensor-consumer-group
output:
destination: iot.edge.topic
@rfaita
rfaita / SensorData.java
Created July 27, 2020 13:46
SensorData.java
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;
@rfaita
rfaita / application.yml
Created July 29, 2020 15:37
application.yml
spring:
cloud:
stream:
bindings:
topic1:
destination: topic1
contentType: application/json
group: process
binder: eventhub1
consumer: