This commit is contained in:
esmailian
2025-04-27 11:29:34 +03:30
parent 2641387bc9
commit b19e922011
5 changed files with 9 additions and 83 deletions

23
pom.xml
View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.mmad.testapp</groupId>
@ -83,26 +83,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-stream</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-stream-binder-rabbit</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-stream</artifactId>
<version>3.0.0</version> <!-- or latest 3.x -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>

View File

@ -2,7 +2,6 @@ package com.example.mmad.testapp.controller;
import com.example.mmad.testapp.model.PersonModel;
import com.example.mmad.testapp.service.PersonService;
import com.example.mmad.testapp.service.StreamProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -15,18 +14,15 @@ import javax.validation.Valid;
public class PersonController {
private PersonService personService;
private StreamProducer streamProducer;
@Autowired
public void setPersonService(PersonService personService, StreamProducer streamProducer) {
this.streamProducer = streamProducer;
public void setPersonService(PersonService personService) {
this.personService = personService;
}
@PostMapping("/list")
@ResponseStatus(HttpStatus.OK)
public String listPosts() {
streamProducer.sendMessage("hi hi hi");
return "aaa";
}

View File

@ -1,17 +0,0 @@
package com.example.mmad.testapp.service;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.rabbit.stream.producer.RabbitStreamTemplate;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class StreamProducer {
@Autowired
private RabbitStreamTemplate rabbitStreamTemplate;
public void sendMessage(String message) {
rabbitStreamTemplate.convertAndSend(message);
}
}

View File

@ -1,19 +1,5 @@
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://85.198.8.43:7832/mmrztest
spring.datasource.username=mmrz
spring.datasource.password=fEWp7g44rHf8
#spring.datasource.url=jdbc:postgresql://localhost:5432/version
#spring.datasource.username=cloud
#spring.datasource.password=cloud
#spring.datasource.url=jdbc:postgresql://localhost:5432/mmaddb
#spring.datasource.username=mmad
#spring.datasource.password=me9775
spring.liquibase.change-log=classpath:db/changelog/liquibase-master.xml
spring.sql.init.mode=always
spring.application.name=service-a
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
spring.config.import=configserver:http://localhost:8888/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

View File

@ -1,22 +0,0 @@
spring:
application:
name: servicea
server:
port: 8085
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka
rabbitmq:
stream:
name: my-stream
host: localhost
port: 5552
logging:
level:
org.springframework.cloud.stream: DEBUG
org.springframework.amqp: DEBUG