-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored processor + Removed spring cloud sleuth from all services
- Loading branch information
Showing
21 changed files
with
96 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...r/src/main/java/com/rabbit/springcloudstream/processor/configs/ProcessorStreamConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.rabbit.springcloudstream.processor.configs; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cloud.stream.annotation.EnableBinding; | ||
import org.springframework.cloud.stream.messaging.Processor; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Slf4j | ||
@Configuration("processorStreamConfig") | ||
@EnableBinding(Processor.class) | ||
public class ProcessorStreamConfig { | ||
|
||
// no-op | ||
} |
19 changes: 10 additions & 9 deletions
19
...am/processor/configs/ProcessorConfig.java → ...services/ProcessorTransformerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
package com.rabbit.springcloudstream.processor.configs; | ||
package com.rabbit.springcloudstream.processor.services; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cloud.stream.annotation.EnableBinding; | ||
import org.springframework.cloud.stream.messaging.Processor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.integration.annotation.Transformer; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
|
||
|
||
@Slf4j | ||
@Configuration("processorConfig") | ||
@EnableBinding(Processor.class) | ||
public class ProcessorConfig { | ||
@Service("processorTransformerService") | ||
public class ProcessorTransformerService { | ||
|
||
int totalMsg = 1; | ||
|
||
@Transformer( | ||
inputChannel = Processor.INPUT, | ||
outputChannel = Processor.OUTPUT | ||
) | ||
public Object transform(final Long timestamp) { | ||
|
||
log.info("Transform: {}", timestamp); | ||
|
||
final DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:yy"); | ||
return dateFormat.format(timestamp); | ||
final String stringTimestamp = dateFormat.format(timestamp); | ||
log.info("Transform message {} from {} to {}", totalMsg, timestamp, stringTimestamp); | ||
totalMsg++; | ||
return stringTimestamp; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Spring KAFKA | ||
spring.kafka.bootstrap-servers = localhost:9092 | ||
spring.kafka.client-id = ${spring.application.name} | ||
spring.kafka.consumer.bootstrap-servers = ${spring.kafka.bootstrap-servers} | ||
spring.kafka.consumer.client-id = ${spring.kafka.client-id} | ||
|
||
### Spring Cloud STREAM - KAFKA | ||
spring.cloud.stream.kafka.binder.brokers = localhost:9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### Spring RABBITMQ | ||
spring.rabbitmq.host = localhost | ||
spring.rabbitmq.port = 5672 | ||
spring.rabbitmq.username = rabbit | ||
spring.rabbitmq.password = rabbit | ||
|
||
### Spring Cloud STREAM - RABBITMQ | ||
spring.cloud.stream.rabbit.binder.nodes = localhost:5672 | ||
spring.cloud.stream.rabbit.binder.compression-level = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
sink/src/main/java/com/rabbit/springcloudstream/sink/services/SinkListenerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.rabbit.springcloudstream.sink.services; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cloud.stream.annotation.StreamListener; | ||
import org.springframework.cloud.stream.messaging.Sink; | ||
import org.springframework.stereotype.Service; | ||
|
||
|
||
@Slf4j | ||
@Service("sinkListenerService") | ||
public class SinkListenerService { | ||
|
||
int totalMsg = 1; | ||
|
||
@StreamListener(Sink.INPUT) | ||
public void loggerSink(final String date) { | ||
|
||
log.info("Received message {}: {}", totalMsg, date); | ||
totalMsg++; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
### Spring Cloud SLEUTH - KAFKA | ||
spring.sleuth.messaging.kafka.enabled = true | ||
spring.sleuth.messaging.kakfa.remote-service-name = kafka | ||
|
||
### Spring KAFKA | ||
spring.kafka.bootstrap-servers = localhost:9092 | ||
spring.kafka.client-id = ${spring.application.name} | ||
spring.kafka.consumer.bootstrap-servers = ${spring.kafka.bootstrap-servers} | ||
spring.kafka.consumer.client-id = ${spring.kafka.client-id} | ||
spring.kafka.bootstrap-servers = localhost:9092 | ||
spring.kafka.client-id = ${spring.application.name} | ||
spring.kafka.consumer.bootstrap-servers = ${spring.kafka.bootstrap-servers} | ||
spring.kafka.consumer.client-id = ${spring.kafka.client-id} | ||
|
||
### Spring Cloud STREAM - KAFKA | ||
spring.cloud.stream.kafka.binder.brokers = localhost:9092 | ||
spring.cloud.stream.kafka.binder.brokers = localhost:9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
source/src/main/java/com/rabbit/springcloudstream/source/configs/SourceSchedulingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
### Spring Cloud SLEUTH - KAFKA | ||
spring.sleuth.messaging.kafka.enabled = true | ||
spring.sleuth.messaging.kakfa.remote-service-name = kafka | ||
|
||
### Spring KAFKA | ||
spring.kafka.bootstrap-servers = localhost:9092 | ||
spring.kafka.client-id = ${spring.application.name} | ||
spring.kafka.producer.bootstrap-servers = ${spring.kafka.bootstrap-servers} | ||
spring.kafka.producer.client-id = ${spring.kafka.client-id} | ||
spring.kafka.bootstrap-servers = localhost:9092 | ||
spring.kafka.client-id = ${spring.application.name} | ||
spring.kafka.producer.bootstrap-servers = ${spring.kafka.bootstrap-servers} | ||
spring.kafka.producer.client-id = ${spring.kafka.client-id} | ||
|
||
### Spring Cloud STREAM - KAFKA | ||
spring.cloud.stream.kafka.binder.brokers = localhost:9092 | ||
spring.cloud.stream.kafka.binder.brokers = localhost:9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.