Skip to content

Commit ec843da

Browse files
author
ardizioa
committed
Code improvement
1 parent d9a5625 commit ec843da

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

src/main/java/com/aardizio/SpringReactiveApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class SpringReactiveApplication implements ApplicationListener<Applicatio
1818

1919
@Qualifier("simpleConsumer")
2020
@Autowired
21-
private KafkaReceiver<String,String> receiver;
21+
private KafkaReceiver<String,String> receiver;
2222

2323

2424
public static void main(String[] args) {

src/main/java/com/aardizio/resource/HotelController.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,18 @@ public Mono<Hotels> delete(@PathVariable String id) {
6565
tracer.currentSpan().tag("hotelid", hotel.getId());
6666
LOGGER.info("creating a journal 1");
6767

68-
ProducerRecord<String,String> record = new ProducerRecord<String,String>("prova", null, hotel.getId(), hotel.toString());
69-
Mono<SenderRecord<String,String,String>> mono = Mono.just(SenderRecord.create(record, null));
70-
71-
return hotelRepo.save(hotel)
72-
.then()
73-
.and(hotelSender.send(mono)
74-
.doOnError(e -> LOGGER.error(e.toString()))
75-
.doOnNext(m -> LOGGER.info("Produced event : {}" , m.toString())))
76-
.map(v -> hotel)
77-
.doOnError(e -> LOGGER.error("Error during hotel creation {}" , e));
68+
return hotelRepo.save(hotel)
69+
.flatMapMany(h -> {
70+
ProducerRecord<String,String> record = new ProducerRecord<String,String>("prova", null, hotel.getId(), hotel.toString());
71+
Mono<SenderRecord<String,String,String>> mono = Mono.just(SenderRecord.create(record, null));
72+
return hotelSender.send(mono);
73+
})
74+
.collectList()
75+
.flatMap(m -> Mono.just(hotel));
7876

7977
}
8078

79+
8180
@GetMapping(value = "/hotels/{uuid}", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
8281
MediaType.APPLICATION_JSON_VALUE })
8382
public Mono<Hotels> search(@PathVariable String uuid) {

src/main/resources/application.properties

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ spring.data.cassandra.retry-policy=com.datastax.driver.core.policies.DefaultRetr
1212

1313

1414
# APACHE KAFKA (KafkaProperties)
15-
spring.kafka.bootstrap-servers=localhost:9092
15+
spring.kafka.bootstrap-servers=10.115.137.229:9092
1616

1717
#Distributed tracing
1818
spring.sleuth.web.additionalSkipPattern=
1919
spring.application.name=Spring-Reactive
20-
logging.level.org.springframework.cloud.sleuth=DEBUG
20+
logging.level.org.springframework.cloud.sleuth=INFO
2121
spring.sleuth.baggage-keys=brequestId,bgroupId
2222
propagation-keys=requestId,groupId
2323
management.endpoints.web.exposure.include=jolokia
@@ -40,8 +40,8 @@ spring.devtools.remote.debug.local-port=8787
4040
#logging.file=server.log
4141
logging.level.org.springframework=INFO
4242
logging.level.org.springframework.data.mongodb.core.MongoTemplate=INFO
43-
logging.level.org.hibernate.SQL=TRACE
44-
logging.level.org.hibernate.type=TRACE
43+
logging.level.org.hibernate.SQL=INFO
44+
logging.level.org.hibernate.type=INFO
4545
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
4646
# Settings query logger normal to trace you will see also the bind parameters
4747
logging.level.com.datastax.driver.core.QueryLogger.NORMAL=TRACE
@@ -50,7 +50,4 @@ logging.level.com.datastax.driver.core.QueryLogger.ERROR=TRACE
5050
# Appender pattern for output to the console. Only supported with the default logback setup.
5151
# Appender pattern for output to the console. Only supported with the default logback setup.
5252
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS},${spring.application.name},${PID:- },[%thread],%-5level,%c{1},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-B3-ParentSpanId:-},%X{X-Span-Name:-},%X{TAGS:-},%X{X-Span-Export:-},%m%n
53-
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS},${spring.application.name},${PID:- },[%thread],%-5level,%c{1},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-B3-ParentSpanId:-},%X{X-Span-Name:-},%X{TAGS:-},%X{X-Span-Export:-},%m%n
54-
55-
56-
debug=true
53+
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS},${spring.application.name},${PID:- },[%thread],%-5level,%c{1},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-B3-ParentSpanId:-},%X{X-Span-Name:-},%X{TAGS:-},%X{X-Span-Export:-},%m%n

0 commit comments

Comments
 (0)