Change project to run spring-boot locally and kafka,zoo and mongo in docker-compose
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
/.idea
|
/.idea
|
||||||
/zk-single-kafka-single
|
/zk-single-kafka-single
|
||||||
|
/data0
|
||||||
|
/data1
|
||||||
21
Dockerfile
21
Dockerfile
@@ -1,21 +0,0 @@
|
|||||||
FROM maven:3.6.3-openjdk-8-slim AS build
|
|
||||||
COPY demo-command/src /usr/src/demo-cqrs/demo-command/src
|
|
||||||
COPY demo-command/pom.xml /usr/src/demo-cqrs/demo-command
|
|
||||||
COPY demo-query/src /usr/src/demo-cqrs/demo-query/src
|
|
||||||
COPY demo-query/pom.xml /usr/src/demo-cqrs/demo-query
|
|
||||||
COPY pom.xml /usr/src/demo-cqrs
|
|
||||||
RUN mvn -f /usr/src/demo-cqrs/pom.xml clean package
|
|
||||||
|
|
||||||
FROM openjdk:8-alpine AS demo-command
|
|
||||||
RUN addgroup -S spring && adduser -S spring -G spring
|
|
||||||
USER spring:spring
|
|
||||||
COPY --from=build /usr/src/demo-cqrs/demo-command/target/demo-command-0.0.1-SNAPSHOT.jar /usr/app/demo-command-0.0.1-SNAPSHOT.jar
|
|
||||||
EXPOSE 8081
|
|
||||||
ENTRYPOINT ["java","-jar","/usr/app/demo-command-0.0.1-SNAPSHOT.jar"]
|
|
||||||
|
|
||||||
FROM openjdk:8-alpine AS demo-query
|
|
||||||
RUN addgroup -S spring && adduser -S spring -G spring
|
|
||||||
USER spring:spring
|
|
||||||
COPY --from=build /usr/src/demo-cqrs/demo-query/target/demo-query-0.0.1-SNAPSHOT.jar /usr/app/demo-query-0.0.1-SNAPSHOT.jar
|
|
||||||
EXPOSE 8082
|
|
||||||
ENTRYPOINT ["java","-jar","/usr/app/demo-query-0.0.1-SNAPSHOT.jar"]
|
|
||||||
2
data0/WiredTiger
Normal file
2
data0/WiredTiger
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
WiredTiger
|
||||||
|
WiredTiger 10.0.0: (March 18, 2020)
|
||||||
1
data0/WiredTiger.lock
Normal file
1
data0/WiredTiger.lock
Normal file
@@ -0,0 +1 @@
|
|||||||
|
WiredTiger lock file
|
||||||
6
data0/WiredTiger.turtle
Normal file
6
data0/WiredTiger.turtle
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
WiredTiger version string
|
||||||
|
WiredTiger 10.0.0: (March 18, 2020)
|
||||||
|
WiredTiger version
|
||||||
|
major=10,minor=0,patch=0
|
||||||
|
file:WiredTiger.wt
|
||||||
|
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none),block_allocation=best,block_compressor=,cache_resident=false,checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1),checkpoint=(WiredTigerCheckpoint.45=(addr="018381e4539bcb7f8481e41f4fdcd18581e4d2e42e9a808080e3010fc0e23fc0",order=45,time=1612453682,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=23,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=120,run_write_gen=98)),checkpoint_backup_info=,checkpoint_lsn=(8,19072)
|
||||||
BIN
data0/WiredTiger.wt
Normal file
BIN
data0/WiredTiger.wt
Normal file
Binary file not shown.
BIN
data0/WiredTigerHS.wt
Normal file
BIN
data0/WiredTigerHS.wt
Normal file
Binary file not shown.
BIN
data0/_mdb_catalog.wt
Normal file
BIN
data0/_mdb_catalog.wt
Normal file
Binary file not shown.
BIN
data0/collection-0--4349258851694291604.wt
Normal file
BIN
data0/collection-0--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-10--4349258851694291604.wt
Normal file
BIN
data0/collection-10--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-2--4349258851694291604.wt
Normal file
BIN
data0/collection-2--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-4--4349258851694291604.wt
Normal file
BIN
data0/collection-4--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-7--4349258851694291604.wt
Normal file
BIN
data0/collection-7--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-11-15Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-11-15Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.interim
Normal file
BIN
data0/diagnostic.data/metrics.interim
Normal file
Binary file not shown.
BIN
data0/index-1--4349258851694291604.wt
Normal file
BIN
data0/index-1--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-11--4349258851694291604.wt
Normal file
BIN
data0/index-11--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-3--4349258851694291604.wt
Normal file
BIN
data0/index-3--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-5--4349258851694291604.wt
Normal file
BIN
data0/index-5--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-6--4349258851694291604.wt
Normal file
BIN
data0/index-6--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-8--4349258851694291604.wt
Normal file
BIN
data0/index-8--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-9--4349258851694291604.wt
Normal file
BIN
data0/index-9--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/journal/WiredTigerPreplog.0000000001
Normal file
BIN
data0/journal/WiredTigerPreplog.0000000001
Normal file
Binary file not shown.
BIN
data0/sizeStorer.wt
Normal file
BIN
data0/sizeStorer.wt
Normal file
Binary file not shown.
BIN
data0/storage.bson
Normal file
BIN
data0/storage.bson
Normal file
Binary file not shown.
2
data1/WiredTiger
Normal file
2
data1/WiredTiger
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
WiredTiger
|
||||||
|
WiredTiger 10.0.0: (March 18, 2020)
|
||||||
1
data1/WiredTiger.lock
Normal file
1
data1/WiredTiger.lock
Normal file
@@ -0,0 +1 @@
|
|||||||
|
WiredTiger lock file
|
||||||
6
data1/WiredTiger.turtle
Normal file
6
data1/WiredTiger.turtle
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
WiredTiger version string
|
||||||
|
WiredTiger 10.0.0: (March 18, 2020)
|
||||||
|
WiredTiger version
|
||||||
|
major=10,minor=0,patch=0
|
||||||
|
file:WiredTiger.wt
|
||||||
|
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none),block_allocation=best,block_compressor=,cache_resident=false,checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1),checkpoint=(WiredTigerCheckpoint.45=(addr="018381e4b7f568b08481e41f4fdcd18581e48de68736808080e3010fc0e23fc0",order=45,time=1612453684,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=21,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=120,run_write_gen=98)),checkpoint_backup_info=,checkpoint_lsn=(8,17920)
|
||||||
BIN
data1/WiredTiger.wt
Normal file
BIN
data1/WiredTiger.wt
Normal file
Binary file not shown.
BIN
data1/WiredTigerHS.wt
Normal file
BIN
data1/WiredTigerHS.wt
Normal file
Binary file not shown.
BIN
data1/_mdb_catalog.wt
Normal file
BIN
data1/_mdb_catalog.wt
Normal file
Binary file not shown.
BIN
data1/collection-0-2005600236197793345.wt
Normal file
BIN
data1/collection-0-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-10-2005600236197793345.wt
Normal file
BIN
data1/collection-10-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-2-2005600236197793345.wt
Normal file
BIN
data1/collection-2-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-4-2005600236197793345.wt
Normal file
BIN
data1/collection-4-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-7-2005600236197793345.wt
Normal file
BIN
data1/collection-7-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-11-16Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-11-16Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.interim
Normal file
BIN
data1/diagnostic.data/metrics.interim
Normal file
Binary file not shown.
BIN
data1/index-1-2005600236197793345.wt
Normal file
BIN
data1/index-1-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-11-2005600236197793345.wt
Normal file
BIN
data1/index-11-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-3-2005600236197793345.wt
Normal file
BIN
data1/index-3-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-5-2005600236197793345.wt
Normal file
BIN
data1/index-5-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-6-2005600236197793345.wt
Normal file
BIN
data1/index-6-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-8-2005600236197793345.wt
Normal file
BIN
data1/index-8-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-9-2005600236197793345.wt
Normal file
BIN
data1/index-9-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/sizeStorer.wt
Normal file
BIN
data1/sizeStorer.wt
Normal file
Binary file not shown.
BIN
data1/storage.bson
Normal file
BIN
data1/storage.bson
Normal file
Binary file not shown.
@@ -3,6 +3,13 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-mongodb</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>es.dbiosag</groupId>
|
<groupId>es.dbiosag</groupId>
|
||||||
|
|||||||
@@ -1,27 +1,20 @@
|
|||||||
package es.dbiosag.command.domain.model;
|
package es.dbiosag.command.domain.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import javax.persistence.*;
|
import org.springframework.data.annotation.Id;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
|
||||||
@Table(name = "PHONES")
|
|
||||||
@Builder
|
@Builder
|
||||||
public class Phone {
|
public class Phone {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
@JsonIgnore
|
||||||
@Column(name = "ID_PHONE")
|
private String id;
|
||||||
private Integer id;
|
|
||||||
@Column(name = "NAME")
|
|
||||||
private String name;
|
private String name;
|
||||||
@Column(name = "MODEL")
|
|
||||||
private String model;
|
private String model;
|
||||||
@Column(name = "COLOR")
|
|
||||||
private String color;
|
private String color;
|
||||||
@Column(name = "PRICE")
|
|
||||||
private Double price;
|
private Double price;
|
||||||
@Column(name = "CREATION_DATE")
|
|
||||||
private String creationDate;
|
private String creationDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import lombok.val;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CreateUserService {
|
public class CreateUserService {
|
||||||
@@ -24,7 +22,6 @@ public class CreateUserService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private KafkaPhoneCreatedEventSourcing kafkaPhoneCreatedEventSourcing;
|
private KafkaPhoneCreatedEventSourcing kafkaPhoneCreatedEventSourcing;
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public PhoneCreatedEvent create(CreatePhoneRequest request) {
|
public PhoneCreatedEvent create(CreatePhoneRequest request) {
|
||||||
log.info("Creating new phone");
|
log.info("Creating new phone");
|
||||||
val phone = phoneConverter.createPhoneRequestRequestToPhone(request);
|
val phone = phoneConverter.createPhoneRequestRequestToPhone(request);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package es.dbiosag.command.infrasturcture.repository;
|
package es.dbiosag.command.infrasturcture.repository;
|
||||||
|
|
||||||
import es.dbiosag.command.domain.model.Phone;
|
import es.dbiosag.command.domain.model.Phone;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
public interface PhoneRepository extends MongoRepository<Phone, Integer> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS phones;
|
|
||||||
|
|
||||||
CREATE TABLE phones (
|
|
||||||
id_phone INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
creation_date VARCHAR(250) NOT NULL,
|
|
||||||
name VARCHAR(250) NOT NULL,
|
|
||||||
model VARCHAR(250) NOT NULL,
|
|
||||||
price VARCHAR(250) NOT NULL,
|
|
||||||
color VARCHAR(250) NOT NULL
|
|
||||||
);
|
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8081
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
data:
|
||||||
driverClassName: org.h2.Driver
|
mongodb:
|
||||||
password: 1234
|
authentication-database: examples
|
||||||
url: jdbc:h2:mem:commanddb
|
database: examples
|
||||||
username: sa
|
username: api_user
|
||||||
jpa:
|
password: NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3
|
||||||
database-platform: org.hibernate.dialect.H2Dialect
|
host: localhost
|
||||||
h2:
|
port: 30000
|
||||||
console:
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
bootstrap-servers: kafka1:9092
|
bootstrap-servers: localhost:29092
|
||||||
consumer:
|
consumer:
|
||||||
group-id: test-consumer-group
|
group-id: test-consumer-group
|
||||||
message:
|
message:
|
||||||
|
|||||||
@@ -1,27 +1,19 @@
|
|||||||
package es.dbiosag.query.domain.model;
|
package es.dbiosag.query.domain.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
|
||||||
@Table(name = "PHONES")
|
|
||||||
public class Phone {
|
public class Phone {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
@JsonIgnore
|
||||||
@Column(name = "ID_PHONE")
|
private String id;
|
||||||
private Integer id;
|
|
||||||
@Column(name = "NAME")
|
|
||||||
private String name;
|
private String name;
|
||||||
@Column(name = "MODEL")
|
|
||||||
private String model;
|
private String model;
|
||||||
@Column(name = "COLOR")
|
|
||||||
private String color;
|
private String color;
|
||||||
@Column(name = "PRICE")
|
|
||||||
private Double price;
|
private Double price;
|
||||||
@Column(name = "CREATION_DATE")
|
|
||||||
private String creationDate;
|
private String creationDate;
|
||||||
|
|
||||||
public Phone(){ }
|
public Phone(){ }
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class FindPhoneService {
|
public class FindPhoneService {
|
||||||
@@ -21,12 +19,9 @@ public class FindPhoneService {
|
|||||||
private PhoneConverter phoneConverter;
|
private PhoneConverter phoneConverter;
|
||||||
|
|
||||||
public PhoneResponse findByName(String name) throws PhoneNotFoundException {
|
public PhoneResponse findByName(String name) throws PhoneNotFoundException {
|
||||||
Optional<Phone> phone = phoneRepository.findByName(name);
|
Phone phone = phoneRepository.findByName(name).orElseThrow(() -> new PhoneNotFoundException(name, "Phone not found"));
|
||||||
if(!phone.isPresent()) {
|
|
||||||
throw new PhoneNotFoundException(name, "Phone not found");
|
|
||||||
}
|
|
||||||
log.info("Find phone: {}", phone);
|
log.info("Find phone: {}", phone);
|
||||||
return phoneConverter.phoneToPhoneResponse(phone.get());
|
return phoneConverter.phoneToPhoneResponse(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPhone(Phone p) {
|
public void createPhone(Phone p) {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package es.dbiosag.query.infrastructure.repository;
|
package es.dbiosag.query.infrastructure.repository;
|
||||||
|
|
||||||
import es.dbiosag.query.domain.model.Phone;
|
import es.dbiosag.query.domain.model.Phone;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
public interface PhoneRepository extends MongoRepository<Phone, Integer> {
|
||||||
|
|
||||||
Optional<Phone> findByName(String name);
|
Optional<Phone> findByName(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
server:
|
server:
|
||||||
port: 8082
|
port: 8082
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
data:
|
||||||
driverClassName: org.h2.Driver
|
mongodb:
|
||||||
password: 1234
|
authentication-database: examples
|
||||||
url: jdbc:h2:mem:querydb
|
database: examples
|
||||||
username: sa
|
username: api_user
|
||||||
jpa:
|
password: NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3
|
||||||
database-platform: org.hibernate.dialect.H2Dialect
|
host: localhost
|
||||||
h2:
|
port: 30001
|
||||||
console:
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
bootstrap-servers: kafka1:9092
|
bootstrap-servers: localhost:29092
|
||||||
consumer:
|
consumer:
|
||||||
group-id: test-consumer-group
|
group-id: test-consumer-group
|
||||||
message:
|
message:
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS phones;
|
|
||||||
|
|
||||||
CREATE TABLE phones (
|
|
||||||
id_phone INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
creation_date VARCHAR(250) NOT NULL,
|
|
||||||
name VARCHAR(250) NOT NULL,
|
|
||||||
model VARCHAR(250) NOT NULL,
|
|
||||||
price VARCHAR(250) NOT NULL,
|
|
||||||
color VARCHAR(250) NOT NULL
|
|
||||||
);
|
|
||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "2181:2181"
|
- "2181:2181"
|
||||||
networks:
|
networks:
|
||||||
- kafka_net
|
- my_network
|
||||||
environment:
|
environment:
|
||||||
ZOO_MY_ID: 1
|
ZOO_MY_ID: 1
|
||||||
ZOO_PORT: 2181
|
ZOO_PORT: 2181
|
||||||
@@ -16,6 +16,40 @@ services:
|
|||||||
- ./zk-single-kafka-single/zoo1/data:/data
|
- ./zk-single-kafka-single/zoo1/data:/data
|
||||||
- ./zk-single-kafka-single/zoo1/datalog:/datalog
|
- ./zk-single-kafka-single/zoo1/datalog:/datalog
|
||||||
|
|
||||||
|
mongo-command:
|
||||||
|
image: mongo:latest
|
||||||
|
container_name: mongo-command
|
||||||
|
hostname: mongo-command
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: secret
|
||||||
|
MONGO_INITDB_DATABASE: examples
|
||||||
|
command: ["--bind_ip_all"]
|
||||||
|
ports:
|
||||||
|
- "30000:27017"
|
||||||
|
networks:
|
||||||
|
- my_network
|
||||||
|
volumes:
|
||||||
|
- ./init-mongo.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||||
|
- ./data0:/data/db
|
||||||
|
|
||||||
|
mongo-query:
|
||||||
|
image: mongo:latest
|
||||||
|
container_name: mongo-query
|
||||||
|
hostname: mongo-query
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: secret
|
||||||
|
MONGO_INITDB_DATABASE: examples
|
||||||
|
command: ["--bind_ip_all"]
|
||||||
|
ports:
|
||||||
|
- "30001:27017"
|
||||||
|
networks:
|
||||||
|
- my_network
|
||||||
|
volumes:
|
||||||
|
- ./init-mongo.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||||
|
- ./data1:/data/db
|
||||||
|
|
||||||
kafka1:
|
kafka1:
|
||||||
image: confluentinc/cp-kafka:5.5.1
|
image: confluentinc/cp-kafka:5.5.1
|
||||||
hostname: kafka1
|
hostname: kafka1
|
||||||
@@ -36,55 +70,13 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- zoo1
|
- zoo1
|
||||||
networks:
|
networks:
|
||||||
- kafka_net
|
- my_network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "nc", "-vz", "localhost", "9092" ]
|
test: [ "CMD", "nc", "-vz", "localhost", "9092" ]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
demo-command:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: demo-command
|
|
||||||
hostname: demo-command
|
|
||||||
ports:
|
|
||||||
- "8081:8081"
|
|
||||||
depends_on:
|
|
||||||
kafka1:
|
|
||||||
condition: service_healthy
|
|
||||||
networks:
|
|
||||||
- kafka_net
|
|
||||||
|
|
||||||
demo-query-1:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: demo-query
|
|
||||||
hostname: demo-query-1
|
|
||||||
ports:
|
|
||||||
- "8082:8082"
|
|
||||||
depends_on:
|
|
||||||
kafka1:
|
|
||||||
condition: service_healthy
|
|
||||||
networks:
|
|
||||||
- kafka_net
|
|
||||||
|
|
||||||
# demo-query-2:
|
|
||||||
# build:
|
|
||||||
# context: demo-query
|
|
||||||
# dockerfile: Dockerfile
|
|
||||||
# image: demo-query
|
|
||||||
# hostname: demo-query-2
|
|
||||||
# ports:
|
|
||||||
# - "8083:8082"
|
|
||||||
# depends_on:
|
|
||||||
# kafka1:
|
|
||||||
# condition: service_healthy
|
|
||||||
# networks:
|
|
||||||
# - kafka_net
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
kafka_net:
|
my_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
8
init-mongo.js
Normal file
8
init-mongo.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
db.createCollection('examples');
|
||||||
|
db.createUser(
|
||||||
|
{
|
||||||
|
user: 'api_user',
|
||||||
|
pwd: 'NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3',
|
||||||
|
roles: [{ role: 'readWrite', db: 'examples' }],
|
||||||
|
},
|
||||||
|
);
|
||||||
2
pom.xml
2
pom.xml
@@ -36,7 +36,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.kafka</groupId>
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
|||||||
Reference in New Issue
Block a user