Skip to content

Commit

Permalink
RSWW-56 transport-service: add write part of cqrs
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Cichowski <[email protected]>
  • Loading branch information
pcichowski committed May 10, 2024
1 parent 91626f1 commit a2b64de
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public String test() {

@RabbitListener(queues = "transports.requests.getTransportsBySearchQuery")
public void consumeGetTransportsRequest(GetTransportsBySearchQueryRequestDto requestDto) {
long startTime = System.currentTimeMillis();

GetTransportsBySearchQueryResponseDto responseDto = transportsService.getTransportsBySearchQuery(requestDto);

long endTime = System.currentTimeMillis();
System.out.println("Send transports response size " + responseDto.getTransportDtoList().size());
System.out.println("Service call took " + (endTime - startTime) + " ms");

rabbitTemplate.convertAndSend("transports.responses.getTransportsBySearchQuery", responseDto);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.microarchitecturovisco.transport.model.cqrs.aggregates;

import lombok.RequiredArgsConstructor;
import org.microarchitecturovisco.transport.model.cqrs.commands.CreateTransportCommand;
import org.microarchitecturovisco.transport.model.cqrs.commands.UpdateTransportCommand;
import org.microarchitecturovisco.transport.model.domain.Transport;
import org.microarchitecturovisco.transport.repositories.TransportRepository;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class TransportAggregate {

private TransportRepository transportRepository;

public Transport handleCreateTransportCommand(CreateTransportCommand command) {

// TODO create transport logic
return null;
}

public Transport handleUpdateTransportCommand(UpdateTransportCommand command) {
// TODO update transport logic
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.microarchitecturovisco.transport.model.cqrs.commands;

import org.microarchitecturovisco.transport.model.dto.TransportDto;

import java.time.LocalDateTime;

public class CreateTransportCommand {
private String uuid;
private LocalDateTime commandCreatedTime;

private TransportDto transportDto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.microarchitecturovisco.transport.model.cqrs.commands;

import lombok.Builder;
import lombok.Data;
import org.microarchitecturovisco.transport.model.dto.TransportDto;

import java.time.LocalDateTime;

@Data
@Builder
public class UpdateTransportCommand {
private String uuid;
private LocalDateTime commandCreatedTime;

private TransportDto transportDto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.microarchitecturovisco.transport.model.cqrs.projections;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class TransportProjection {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.microarchitecturovisco.transport.model.cqrs.queries;

public class QueryTransport {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring.application.name=transport-service

server.port=0

eureka.client.service-url.defaultZone=http://discovery:8010/eureka
eureka.client.service-url.defaultZone=http://localhost:8010/eureka

eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=${spring.application.name}:${spring.application.instance_id:${random.value}}
Expand Down

0 comments on commit a2b64de

Please sign in to comment.