Skip to content

--BJS2-97084 - GoalCompletedEvent notification setup with Redis -- User_service#3497

Open
flesheatingcat wants to merge 5 commits intophoenix-master-stream12from
feature/BJS2-97084
Open

--BJS2-97084 - GoalCompletedEvent notification setup with Redis -- User_service#3497
flesheatingcat wants to merge 5 commits intophoenix-master-stream12from
feature/BJS2-97084

Conversation

@flesheatingcat
Copy link
Copy Markdown

No description provided.

@github-actions
Copy link
Copy Markdown

⚠️ ОШЫБКА: Сборка завалилась: либо ошибки компиляции, либо не прошли тесты, либо возникли ошибки в стиле кода. Пожалуйста, проверь логи и внеси соответствующие изменения в ПР. После этого красная ошибка ниже должна пропасть, но этот комментарий останется - так и должно быть.

@github-actions
Copy link
Copy Markdown

⚠️ ОШЫБКА: Сборка завалилась: либо ошибки компиляции, либо не прошли тесты, либо возникли ошибки в стиле кода. Пожалуйста, проверь логи и внеси соответствующие изменения в ПР. После этого красная ошибка ниже должна пропасть, но этот комментарий останется - так и должно быть.

@flesheatingcat flesheatingcat changed the title --BJS2-97084 - GoalCompletedEvent notification setup with Redis --BJS2-97084 - GoalCompletedEvent notification setup with Redis -- User_service Nov 10, 2025
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему у всех тут стринга?) почему не хотите работать с json

@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

используй бин

import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
@RequiredArgsConstructor
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

аннотация лишняя

package school.faang.user_service.dto.event;

public record GoalCompletedEvent(
Long userId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оба значения могут быть null?

try {
json = objectMapper.writeValueAsString(goalCompletedEvent);
} catch (JsonProcessingException e) {
throw new DataValidationException("Event to JSON conversion error.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataValidationException не подходит для ошибок сериализации

public void publish(GoalCompletedEvent goalCompletedEvent) {
String json;
try {
json = objectMapper.writeValueAsString(goalCompletedEvent);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Происходит двойная сериализация сначала в JSON строку, потом RedisTemplate снова сериализует эту строку, можно передать напрямую


@Component
@RequiredArgsConstructor
public class GoalCompletedEventPublisher {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опять совсем нет логов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants