Gitlab - Argos ALM by PALO IT

Commit db20524c authored by Julian Pulido's avatar Julian Pulido

Change name package and Structure project

parent 581f7da5
package com.example.http.reactive;
import java.util.function.Consumer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import com.example.http.reactive.dto.Message;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Hooks;
@Slf4j
......@@ -18,36 +12,9 @@ import reactor.core.publisher.Hooks;
@RequiredArgsConstructor
public class HttpReactiveApplication {
public static void main(String[] args) {
SpringApplication.run(HttpReactiveApplication.class, args);
Hooks.enableAutomaticContextPropagation();
}
/*@Bean
Consumer<Message<Rule>> ruleConsumer(){
return rule -> log.info("Consumer rule: {}", rule);
}
@Bean
Consumer<Message<com.example.http.reactive.dto.Message>> messageConsumer(){
return message -> log.info("Consumer message: {}", message);
}*/
/*@Bean
Consumer<Flux<Rule>> ruleConsumer() {
return ruleFlux -> ruleFlux.
doOnNext(rule -> log.info("Consumer rule: {}", rule))
.subscribe();
}*/
@Bean
Consumer<Flux<Message>> messageConsumer() {
return messageFlux -> messageFlux
.doOnNext(message -> log.info("Consumer message: {}", message))
.subscribe();
}
}
package com.example.http.reactive.consumer;
import java.util.function.Consumer;
import org.springframework.stereotype.Component;
import com.example.http.reactive.dto.Rule;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
@Slf4j
@Component
public class RuleConsumer implements Consumer<Flux<Rule>> {
@Override
public void accept(Flux<Rule> ruleFlux) {
ruleFlux
.doOnNext(rule -> log.info("Consumer rule: {}", rule))
.subscribe();
}
}
package com.example.http.reactive.controller;
package com.example.http.reactive.handler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -16,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
@RestController
@RequestMapping("/block")
@RequiredArgsConstructor
public class HttpReactiveController {
public class HttpHandlers {
private final MessageProducerAdapter messageProducerAdapter;
record Response(Boolean status, Object payload){}
......
package com.example.http.reactive.handler;
import java.util.function.Consumer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.example.http.reactive.dto.Message;
import com.example.http.reactive.dto.Rule;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
@Slf4j
@Configuration
public class StreamHandlers {
@Bean
Consumer<Flux<Rule>> ruleConsumer() {
return ruleFlux -> ruleFlux.
doOnNext(rule -> log.info("Consumer rule: {}", rule))
.subscribe();
}
@Bean
Consumer<Flux<Message>> messageConsumer() {
return messageFlux -> messageFlux
.doOnNext(message -> log.info("Consumer message: {}", message))
.subscribe();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment