domingo, 8 de diciembre de 2019

Reactive Spring 2018 Reservation MongoDB

Reactive Spring 2018 Reservation MongoDB




Generate Reservation on MongoDB


After second running the records are appended.


Console:
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2019-12-08 18:14:39.866  INFO 7464 --- [           main] c.b.r.ReservationServiceApplication      : Starting ReservationServiceApplication on DESKTOP-NLF0058 with PID 7464 (D:\proy\reservation-service\target\classes started by bext in D:\proy\reservation-service)
2019-12-08 18:14:39.867  INFO 7464 --- [           main] c.b.r.ReservationServiceApplication      : No active profile set, falling back to default profiles: default
2019-12-08 18:14:40.181  INFO 7464 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive MongoDB repositories in DEFAULT mode.
2019-12-08 18:14:40.210  INFO 7464 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 26ms. Found 1 Reactive MongoDB repository interfaces.
2019-12-08 18:14:40.215  INFO 7464 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2019-12-08 18:14:40.216  INFO 7464 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1ms. Found 0 MongoDB repository interfaces.
2019-12-08 18:14:40.466  INFO 7464 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-12-08 18:14:40.549  INFO 7464 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-12-08 18:14:40.562  INFO 7464 --- [localhost:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:2, serverValue:609}] to localhost:27017
2019-12-08 18:14:40.565  INFO 7464 --- [localhost:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 1]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1674700}
2019-12-08 18:14:40.927  INFO 7464 --- [localhost:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:1, serverValue:610}] to localhost:27017
2019-12-08 18:14:40.928  INFO 7464 --- [localhost:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 1]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1249600}
2019-12-08 18:14:40.932  INFO 7464 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
2019-12-08 18:14:40.934  INFO 7464 --- [           main] c.b.r.ReservationServiceApplication      : Started ReservationServiceApplication in 1.268 seconds (JVM running for 1.83)
2019-12-08 18:14:41.026  INFO 7464 --- [ntLoopGroup-2-3] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:4, serverValue:612}] to localhost:27017
2019-12-08 18:14:41.026  INFO 7464 --- [ntLoopGroup-2-2] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:3, serverValue:611}] to localhost:27017
2019-12-08 18:14:41.026  INFO 7464 --- [ntLoopGroup-2-4] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:5, serverValue:613}] to localhost:27017
2019-12-08 18:14:41.026  INFO 7464 --- [ntLoopGroup-2-6] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:7, serverValue:615}] to localhost:27017
2019-12-08 18:14:41.034  INFO 7464 --- [ntLoopGroup-2-5] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:6, serverValue:614}] to localhost:27017
2019-12-08 18:14:41.035  INFO 7464 --- [ntLoopGroup-2-7] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:8, serverValue:616}] to localhost:27017
2019-12-08 18:14:41.036  INFO 7464 --- [ntLoopGroup-2-8] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:9, serverValue:617}] to localhost:27017
2019-12-08 18:14:41.043  INFO 7464 --- [ntLoopGroup-2-9] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:10, serverValue:618}] to localhost:27017

Process finished with exit code -1


Deleting All records before the work


Add Logging


On Console the log on save is showed.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2019-12-08 18:26:19.044  INFO 13212 --- [           main] c.b.r.ReservationServiceApplication      : Starting ReservationServiceApplication on DESKTOP-NLF0058 with PID 13212 (D:\proy\reservation-service\target\classes started by bext in D:\proy\reservation-service)
2019-12-08 18:26:19.047  INFO 13212 --- [           main] c.b.r.ReservationServiceApplication      : No active profile set, falling back to default profiles: default
2019-12-08 18:26:19.351  INFO 13212 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive MongoDB repositories in DEFAULT mode.
2019-12-08 18:26:19.384  INFO 13212 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 29ms. Found 1 Reactive MongoDB repository interfaces.
2019-12-08 18:26:19.387  INFO 13212 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2019-12-08 18:26:19.388  INFO 13212 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1ms. Found 0 MongoDB repository interfaces.
2019-12-08 18:26:19.642  INFO 13212 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-12-08 18:26:19.727  INFO 13212 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-12-08 18:26:19.739  INFO 13212 --- [localhost:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:2, serverValue:642}] to localhost:27017
2019-12-08 18:26:19.742  INFO 13212 --- [localhost:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 1]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1610800}
2019-12-08 18:26:20.099  INFO 13212 --- [localhost:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:1, serverValue:644}] to localhost:27017
2019-12-08 18:26:20.100  INFO 13212 --- [localhost:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 1]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1308100}
2019-12-08 18:26:20.110  INFO 13212 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
2019-12-08 18:26:20.112  INFO 13212 --- [           main] c.b.r.ReservationServiceApplication      : Started ReservationServiceApplication in 1.261 seconds (JVM running for 1.813)
2019-12-08 18:26:20.163  INFO 13212 --- [ntLoopGroup-2-2] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:3, serverValue:645}] to localhost:27017
2019-12-08 18:26:20.194  INFO 13212 --- [ntLoopGroup-2-3] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:4, serverValue:646}] to localhost:27017
2019-12-08 18:26:20.195  INFO 13212 --- [ntLoopGroup-2-4] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:5, serverValue:647}] to localhost:27017
2019-12-08 18:26:20.201  INFO 13212 --- [ntLoopGroup-2-5] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:6, serverValue:648}] to localhost:27017
2019-12-08 18:26:20.205  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950b, nombre=Luis)
2019-12-08 18:26:20.206  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950c, nombre=Daisy)
2019-12-08 18:26:20.206  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950d, nombre=McPato)
2019-12-08 18:26:20.206  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e29509, nombre=Hugo)
2019-12-08 18:26:20.206  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950a, nombre=Paco)
2019-12-08 18:26:20.207  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950e, nombre=Beto)
2019-12-08 18:26:20.208  INFO 13212 --- [ntLoopGroup-2-5] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e2950f, nombre=Guille)
2019-12-08 18:26:20.208  INFO 13212 --- [ntLoopGroup-2-4] c.b.r.SamplaDataInitializr               : Reservation(id=5ded94ace4f1762422e29510, nombre=Juan)


Adding logging on different steps of the Fluxes, just ilustrative.


On Console the logging for the respective Fluxes.
...
2019-12-08 18:31:29.945  INFO 16072 --- [ntLoopGroup-2-3] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:4, serverValue:661}] to localhost:27017
2019-12-08 18:31:29.947  INFO 16072 --- [ntLoopGroup-2-2] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd8e, nombre=Paco)
2019-12-08 18:31:29.947  INFO 16072 --- [ntLoopGroup-2-2] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd8d, nombre=Hugo)
2019-12-08 18:31:29.954  INFO 16072 --- [ntLoopGroup-2-2] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd8f, nombre=Luis)
2019-12-08 18:31:29.955  INFO 16072 --- [ntLoopGroup-2-2] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd91, nombre=McPato)
2019-12-08 18:31:29.956  INFO 16072 --- [ntLoopGroup-2-3] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd92, nombre=Beto)
2019-12-08 18:31:29.956  INFO 16072 --- [ntLoopGroup-2-4] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:5, serverValue:662}] to localhost:27017
2019-12-08 18:31:29.957  INFO 16072 --- [ntLoopGroup-2-3] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd93, nombre=Guille)
2019-12-08 18:31:29.958  INFO 16072 --- [ntLoopGroup-2-4] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd90, nombre=Daisy)
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [ntLoopGroup-2-2] c.b.r.SamplaDataInitializr               : Reservation(id=5ded95e13880f842320efd94, nombre=Juan)
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : null
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Hugo
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Paco
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Luis
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Daisy
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : McPato
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Beto
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Guille
2019-12-08 18:31:29.959  INFO 16072 --- [           main] c.b.r.SamplaDataInitializr               : Juan

Optimizing the code for java 11, using var and compacting


Console

...
2019-12-08 18:34:26.080  INFO 3024 --- [ntLoopGroup-2-7] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:8, serverValue:675}] to localhost:27017
2019-12-08 18:34:26.095  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969eda, nombre=Hugo)
2019-12-08 18:34:26.095  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969edb, nombre=Paco)
2019-12-08 18:34:26.095  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969edc, nombre=Luis)
2019-12-08 18:34:26.095  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969edf, nombre=Beto)
2019-12-08 18:34:26.096  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969edd, nombre=Daisy)
2019-12-08 18:34:26.096  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969ee1, nombre=Juan)
2019-12-08 18:34:26.096  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969ede, nombre=McPato)
2019-12-08 18:34:26.096  INFO 3024 --- [ntLoopGroup-2-7] c.b.r.SamplaDataInitializr               : Reservation(id=5ded969205c528360d969ee0, nombre=Guille)



eot

No hay comentarios:

Publicar un comentario