-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
publishers/src/main/java/br/com/bscpaz/publisher/configurations/RabbitmqConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package br.com.bscpaz.publisher.configurations; | ||
|
||
public class RabbitmqConfig { | ||
|
||
public static final String JUSTICE_V1_DOCS_EXCHANGE = "justice.v1.documents"; | ||
public static final String JUSTICE_V1_DOCS_ROUTING_KEY = "document-signed."; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
...c/main/java/br/com/bscpaz/publisher/controllers/v1/impl/BasicPublisherControllerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
package br.com.bscpaz.publisher.controllers.v1.impl; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import br.com.bscpaz.publisher.controllers.dtos.ResponseDTO; | ||
import br.com.bscpaz.publisher.controllers.utils.ResponseUtil; | ||
import br.com.bscpaz.publisher.controllers.v1.BasicPublisherController; | ||
import br.com.bscpaz.publisher.services.BasicPublisherService; | ||
|
||
@RestController | ||
public class BasicPublisherControllerImpl implements BasicPublisherController { | ||
|
||
@Autowired | ||
private BasicPublisherService basicPublisherController; | ||
|
||
@Override | ||
public ResponseEntity<ResponseDTO<String>> helloWorldRabbitmq() { | ||
return ResponseUtil.success("Message published into rabbitmq!"); | ||
try { | ||
String message = basicPublisherController.helloWorldRabbitmq(); | ||
return ResponseUtil.success(message, null); | ||
} catch (Exception e) { | ||
return ResponseUtil.internalServerError(e.getMessage(), "Sorry, something went wrong."); | ||
} | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
publishers/src/main/java/br/com/bscpaz/publisher/services/BasicPublisherService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package br.com.bscpaz.publisher.services; | ||
|
||
public interface BasicPublisherService { | ||
|
||
String helloWorldRabbitmq(); | ||
} |
29 changes: 29 additions & 0 deletions
29
...ishers/src/main/java/br/com/bscpaz/publisher/services/impl/BasicPublisherServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package br.com.bscpaz.publisher.services.impl; | ||
|
||
import org.springframework.amqp.core.Message; | ||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import br.com.bscpaz.publisher.configurations.RabbitmqConfig; | ||
import br.com.bscpaz.publisher.services.BasicPublisherService; | ||
|
||
@Service | ||
public class BasicPublisherServiceImpl implements BasicPublisherService { | ||
|
||
@Autowired | ||
private RabbitTemplate rabbitTemplate; | ||
|
||
@Override | ||
public String helloWorldRabbitmq() { | ||
String helloWorld = "Hello World"; | ||
Message message = new Message(helloWorld.getBytes()); | ||
|
||
rabbitTemplate.send( | ||
RabbitmqConfig.JUSTICE_V1_DOCS_EXCHANGE, | ||
RabbitmqConfig.JUSTICE_V1_DOCS_ROUTING_KEY + "1", | ||
message); | ||
|
||
return "Message has been sent to RabbitMQ!"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
spring: | ||
rabbitmq: | ||
host: localhost | ||
port: 5672 | ||
username: system_user | ||
password: 123456 | ||
virtual-host: justice-prd |