| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| spring.main.allow-bean-definition-overriding=true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package tv.codely.apps.backoffice.backend.command; | ||
|
|
||
| import tv.codely.shared.infrastructure.bus.event.rabbitmq.RabbitMqDomainEventsConsumer; | ||
| import tv.codely.shared.infrastructure.cli.ConsoleCommand; | ||
|
|
||
| public final class ConsumeRabbitMqDomainEventsCommand extends ConsoleCommand { | ||
|
|
||
| private final RabbitMqDomainEventsConsumer consumer; | ||
|
|
||
| public ConsumeRabbitMqDomainEventsCommand(RabbitMqDomainEventsConsumer consumer) { | ||
| this.consumer = consumer; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(String[] args) { | ||
| consumer.consume("backoffice"); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package tv.codely.apps.mooc.backend.controller.playground; | ||
|
|
||
| import org.springframework.amqp.core.Message; | ||
| import org.springframework.amqp.core.MessagePropertiesBuilder; | ||
| import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import tv.codely.shared.domain.Utils; | ||
|
|
||
| @RestController | ||
| record DomainEventPostController(RabbitTemplate rabbitTemplate) { | ||
| @PostMapping(value = "/domain-events") | ||
| public ResponseEntity<String> index(@RequestBody Request request) { | ||
| System.out.println(request.eventName()); | ||
|
|
||
| var serializedEvent = Utils.jsonEncode(request.eventRaw()); | ||
|
|
||
| Message message = new Message( | ||
| serializedEvent.getBytes(), | ||
| MessagePropertiesBuilder.newInstance().setContentEncoding("utf-8").setContentType("application/json").build() | ||
| ); | ||
|
|
||
| rabbitTemplate.send("domain_events", request.eventName(), message); | ||
|
|
||
| return new ResponseEntity<>(HttpStatus.CREATED); | ||
| } | ||
| } | ||
|
|
||
| final class Request { | ||
|
|
||
| private String eventName; | ||
| private Object eventRaw; | ||
|
|
||
| public void setEventName(String eventName) { | ||
| this.eventName = eventName; | ||
| } | ||
|
|
||
| public void setEventRaw(Object eventRaw) { | ||
| this.eventRaw = eventRaw; | ||
| } | ||
|
|
||
| String eventName() { | ||
| return eventName; | ||
| } | ||
|
|
||
| Object eventRaw() { | ||
| return eventRaw; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| POST http://localhost:8030/domain-events | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "eventName": "course.created", | ||
| "eventRaw": { | ||
| "data": { | ||
| "id": "{{$random.uuid}}", | ||
| "type": "course.created", | ||
| "occurred_on": "2023-11-14 10:00:00", | ||
| "attributes": { | ||
| "id": "c3a11f1d-512e-420b-aeae-e687a3c449aa", | ||
| "name": "Demo course", | ||
| "duration": "2 days" | ||
| } | ||
| }, | ||
| "meta": { | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ### | ||
| POST http://localhost:8030/domain-events | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "eventName": "course.renamed", | ||
| "eventRaw": { | ||
| "data": { | ||
| "id": "{{$random.uuid}}", | ||
| "type": "course.renamed", | ||
| "occurred_on": "2023-11-14 10:00:00", | ||
| "attributes": { | ||
| "id": "7b081a3e-f90e-4efe-a3a5-81e853e89c8b", | ||
| "name": "Este es el nombre bueno" | ||
| } | ||
| }, | ||
| "meta": { | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ### | ||
| POST http://localhost:8030/domain-events | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "eventName": "course.renamed", | ||
| "eventRaw": { | ||
| "data": { | ||
| "id": "{{$random.uuid}}", | ||
| "type": "course.renamed", | ||
| "occurred_on": "2022-11-14 10:00:00", | ||
| "attributes": { | ||
| "id": "7b081a3e-f90e-4efe-a3a5-81e853e89c8b", | ||
| "name": "Este es el nombre malo" | ||
| } | ||
| }, | ||
| "meta": { | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| function create_course() { | ||
| eventId=$(uuidgen) | ||
| courseId=$(uuidgen) | ||
| courseName=$(shuf -n3 /usr/share/dict/words | xargs) | ||
| courseDuration=$((1 + RANDOM % 1000)) | ||
|
|
||
| curl -X POST --location "http://localhost:8030/domain-events" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "eventName": "course.created", | ||
| "eventRaw": { | ||
| "data": { | ||
| "id": "'"$eventId"'", | ||
| "type": "course.created", | ||
| "occurred_on": "2023-11-14 10:00:00", | ||
| "attributes": { | ||
| "id": "'"$courseId"'", | ||
| "name": "'"$courseName"'", | ||
| "duration": "'"$courseDuration"' days" | ||
| } | ||
| }, | ||
| "meta": { | ||
| } | ||
| } | ||
| }' | ||
|
|
||
| echo "Created: $courseName" | ||
| } | ||
|
|
||
| while true; do | ||
| create_course & | ||
| sleep 0.001 | ||
| done |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis is a demo
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.