Skip to content

Commit

Permalink
fix: rm neo4j code
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangtien2k3 committed Oct 5, 2024
1 parent f77639f commit 7b13acc
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 243 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MYSQL_HOST=localhost

# redis
REDIS_TAG=7.2.3
REDIS_PORT=6379
REDIS_PORT=6380
REDIS_HOST=redis-container

# elasticsearch
Expand Down
121 changes: 0 additions & 121 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ services:
networks:
- shopapp-network

# elastic search
elasticsearch-container:
container_name: elasticsearch-container
image: elasticsearch:${ELASTICSEARCH_TAG}
ports:
- "${ELASTICSEARCH_PORT}:9200"
environment:
- "discovery.type=single-node"
- "xpack.security.enabled=false"
networks:
- shopapp-network

# neo4j
neo4j-container:
container_name: neo4j-container
Expand All @@ -58,115 +46,6 @@ services:
networks:
- shopapp-network

# zookeeper-01
zookeeper-01:
image: confluentinc/cp-zookeeper:${ZOOKEEPER_TAG}
hostname: zookeeper-01
container_name: zookeeper-01
ports:
- "${ZOOKEEPER_01_PORT}:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_SERVERS: zookeeper-01:2888:3888;zookeeper-02:2888:3888;zookeeper-03:2888:3888
networks:
- shopapp-network

# zookeeper-02
zookeeper-02:
image: confluentinc/cp-zookeeper:${ZOOKEEPER_TAG}
hostname: zookeeper-02
container_name: zookeeper-02
ports:
- "${ZOOKEEPER_02_PORT}:2182"
environment:
ZOOKEEPER_CLIENT_PORT: 2182
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_SERVERS: zookeeper-01:2888:3888;zookeeper-02:2888:3888;zookeeper-03:2888:3888
networks:
- shopapp-network

# zookeeper-03
zookeeper-03:
image: confluentinc/cp-zookeeper:${ZOOKEEPER_TAG}
hostname: zookeeper-03
container_name: zookeeper-03
ports:
- "${ZOOKEEPER_03_PORT}:2183"
environment:
ZOOKEEPER_CLIENT_PORT: 2183
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_SERVERS: zookeeper-01:2888:3888;zookeeper-02:2888:3888;zookeeper-03:2888:3888
networks:
- shopapp-network

# kafka-broker-01
kafka-broker-01:
image: confluentinc/cp-kafka:${KAFKA_TAG}
hostname: kafka-broker-01
container_name: kafka-broker-01
networks:
- shopapp-network
depends_on:
- zookeeper-01
- zookeeper-02
- zookeeper-03
ports:
- "${KAFKA_PORT_01}:9093"
- "${KAFKA_PORT_02}:29092"
- "${KAFKA_PORT_03}:9999"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: "zookeeper-01:2181,zookeeper-02:2182,zookeeper-03:2183"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT,DOCKER:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka-broker-01:19092,EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092,DOCKER://kafka-broker-01:29092
KAFKA_LISTENERS: INTERNAL://0.0.0.0:19092,EXTERNAL://0.0.0.0:9092,DOCKER://0.0.0.0:29092
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9999
KAFKA_JMX_HOSTNAME: ${DOCKER_HOST_IP:-127.0.0.1}
CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: kafka-broker-01:29092
CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
CONFLUENT_METRICS_ENABLE: 'true'
CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"

# shopapp connect
shopapp-spring-container:
container_name: shopapp-spring-container
build:
context: .
dockerfile: Dockerfile
ports:
- "8099:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql8-container:3307/shopapp?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
MYSQL_ROOT_PASSWORD: 12042003
REDIS_HOST: redis-container
REDIS_PORT: ${REDIS_PORT}
KAFKA_BROKER_SERVER: kafka-broker-01
KAFKA_BROKER_PORT: 29092
depends_on:
- mysql8-container
- redis-container
- kafka-broker-01
networks:
- shopapp-network
healthcheck:
# test: [ "CMD-SHELL", "curl --fail http://localhost:8080/health_check/health || exit 1" ]
test: [ "CMD-SHELL", "curl --fail http://localhost:8080/api/v1/actuator/health || exit 1" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s

# network
networks:
shopapp-network:
Expand Down
8 changes: 0 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@
<artifactId>flyway-mysql</artifactId>
<version>10.13.0</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
<!-- </dependency>-->
</dependencies>

<build>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.hoangtien2k3.shopappbackend.controllers;

import com.hoangtien2k3.shopappbackend.components.TranslateMessages;
import com.hoangtien2k3.shopappbackend.components.converters.CategoryMessageConverter;
import com.hoangtien2k3.shopappbackend.dtos.CategoryDTO;
import com.hoangtien2k3.shopappbackend.models.Category;
import com.hoangtien2k3.shopappbackend.responses.ApiResponse;
import com.hoangtien2k3.shopappbackend.services.CategoryService;
import com.hoangtien2k3.shopappbackend.utils.Const;
import com.hoangtien2k3.shopappbackend.utils.MessageKeys;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
Expand All @@ -25,7 +22,6 @@
public class CategoryController extends TranslateMessages {

private final CategoryService categoryService;
private final KafkaTemplate<String, Object> kafkaTemplate;

@PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("")
Expand All @@ -47,10 +43,6 @@ public ResponseEntity<?> createCategory(@RequestBody @Valid CategoryDTO category
}
Category newCategory = categoryService.createCategory(categoryDTO);

// send kafka category
this.kafkaTemplate.send(Const.KAFKA_TOPIC_INSERT_CATEGORY, newCategory); // producer
this.kafkaTemplate.setMessageConverter(new CategoryMessageConverter());

return ResponseEntity.ok(ApiResponse.builder().success(true)
.message(translate(MessageKeys.CREATE_CATEGORIES_SUCCESS))
.payload(newCategory)
Expand All @@ -67,7 +59,6 @@ public ResponseEntity<?> createCategory(@RequestBody @Valid CategoryDTO category
public ResponseEntity<ApiResponse<?>> getAllCategories() {
List<Category> categories = categoryService.getAllCategories();
/*kafka get all category*/
this.kafkaTemplate.send(Const.KAFKA_TOPIC_GET_ALL_CATEGORY, categories);
return ResponseEntity.ok(ApiResponse.builder()
.success(true)
.payload(categories)
Expand Down
25 changes: 3 additions & 22 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 8080
port: 8088

spring:
application:
Expand All @@ -8,7 +8,7 @@ spring:
#config mysql8
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${SPRING_DATASOURCE_URL:jdbc:mysql://localhost:3307/shopapp?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true}
url: ${SPRING_DATASOURCE_URL:jdbc:mysql://localhost:3306/shopapp?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true}
username: ${MYSQL_ROOT_USERNAME:root}
password: ${MYSQL_ROOT_PASSWORD:12042003}
jpa:
Expand Down Expand Up @@ -39,30 +39,11 @@ spring:
baseline-on-migrate: true # phiên bản baseline = 1, không thực hiện bất kỳ thay đổi nào trong DB
baseline-version: 0 # nó sẽ chạy V1__alter_some_tables.sql -> nghĩa là nó sẽ chạy cái version lớn hơn cái version hiện tại của chúng ta


data:
#redis memory
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}

# elastic search
# elasticsearch:
# rest:
# uris: http://localhost:9200
# repositories:
# enabled: true

# kafka
kafka:
bootstrap-servers: localhost:9092
producer:
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
properties:
"[spring.json.type.mapping]": "category:com.hoangtien2k3.shopappbackend.models.Category"
consumer:
group-id: groupA
value-deserializer: org.apache.kafka.common.serialization.ByteArrayDeserializer
port: ${REDIS_PORT:6380}

api:
prefix: /api/v1
Expand Down

0 comments on commit 7b13acc

Please sign in to comment.