-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Ar3secchim/feature/configuration-queue
Feature/configuration queue
- Loading branch information
Showing
10 changed files
with
137 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ public Queue queue(){ | |
return new Queue(queueSubs, true); | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/main/java/ada/tech/tenthirty/tvpackages/config/TechnicalVisitQueue.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,17 @@ | ||
package ada.tech.tenthirty.tvpackages.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.amqp.core.Queue; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
@Configuration | ||
public class TechnicalVisitQueue { | ||
@Value("${config.technical-visit.queue.out}") | ||
private String queue; | ||
|
||
@Bean | ||
public Queue queue(){ | ||
return new Queue(queue, true); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/ada/tech/tenthirty/tvpackages/config/WebClientConfig.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,22 @@ | ||
package ada.tech.tenthirty.tvpackages.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
|
||
@Configuration | ||
public class WebClientConfig<StockClient> { | ||
@Value("${config.subscription-package.url}") | ||
private String subscriptionUrl; | ||
|
||
@Value("${config.technical-visit.url}") | ||
private String technicalVisitUrl; | ||
|
||
@Bean | ||
WebClient webClient(){ | ||
return WebClient.builder().baseUrl(subscriptionUrl) | ||
.build(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/ada/tech/tenthirty/tvpackages/queue/NotifyInvoiceProducer.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,23 @@ | ||
package ada.tech.tenthirty.tvpackages.queue; | ||
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.amqp.core.Queue; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import ada.tech.tenthirty.tvpackages.queue.payloads.NotifyInvoiceRequest; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class NotifyInvoiceProducer { | ||
private final RabbitTemplate rabbitTemplate; | ||
private final Queue queue; | ||
private final ObjectMapper objectMapper; | ||
|
||
public void execute (NotifyInvoiceRequest notifyInvoice) throws JsonProcessingException { | ||
String message = objectMapper.writeValueAsString(notifyInvoice); | ||
rabbitTemplate.convertSendAndReceive(queue.getName(), message); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/ada/tech/tenthirty/tvpackages/queue/ScheduleTechnicalVisitProducer.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,24 @@ | ||
package ada.tech.tenthirty.tvpackages.queue; | ||
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.amqp.core.Queue; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import ada.tech.tenthirty.tvpackages.queue.payloads.ScheduleTechnicalVisitRequest; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ScheduleTechnicalVisitProducer { | ||
private final RabbitTemplate rabbitTemplate; | ||
private final Queue queue; | ||
private final ObjectMapper objectMapper; | ||
|
||
public void execute(ScheduleTechnicalVisitRequest ScheduleTechnicalVisit) throws JsonProcessingException { | ||
String message = objectMapper.writeValueAsString(ScheduleTechnicalVisit); | ||
rabbitTemplate.convertSendAndReceive(queue.getName(), message); | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
src/main/java/ada/tech/tenthirty/tvpackages/queue/payloads/NotifyInvoiceRequest.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,12 @@ | ||
package ada.tech.tenthirty.tvpackages.queue.payloads; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class NotifyInvoiceRequest { | ||
private String idUser; | ||
private LocalDateTime issueDate; | ||
private List<Package> listPackage; | ||
} |
9 changes: 9 additions & 0 deletions
9
...main/java/ada/tech/tenthirty/tvpackages/queue/payloads/ScheduleTechnicalVisitRequest.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,9 @@ | ||
package ada.tech.tenthirty.tvpackages.queue.payloads; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ScheduleTechnicalVisitRequest { | ||
private String idUser; | ||
private Boolean newUSer; | ||
} |
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