Skip to content

Commit

Permalink
feat(develop): adding rabbitTemplate to adding at queue
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmoraist committed Oct 4, 2024
1 parent 3465c70 commit aa27e22
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.modelmapper.ModelMapper;


import java.util.List;

Expand All @@ -24,7 +23,7 @@ public class TaskServiceImpl implements TaskService {

private final TaskRepository repository;
private final CommentClient commentClient;
private final ModelMapper modelMapper;
private final RabbitTemplate rabbitTemplate;

@Override
public void createTask(TaskRequest request) {
Expand Down Expand Up @@ -69,14 +68,19 @@ public Task findById(Long id) {

@Transactional
@Override
public void addComment(Long id, CommentDTO comment) {
public void addComment(Long id, CommentDTO dto) {

CommentDTO comment = new CommentDTO(dto.text(), id);

Long commentId = this.commentClient.createComment(id, comment);
this.rabbitTemplate.convertAndSend(
"task.ex",
"",
comment);

Task task = this.findById(id);
task.getComment().add(Comment.builder()
.id(commentId)
.text(comment.text())
.taskId(id)
.build());

this.repository.save(task);
Expand Down

0 comments on commit aa27e22

Please sign in to comment.