/
YuriyMaksimov
/
Lab4_client
Обзор
Документация
Войти
/
YuriyMaksimov
/
Lab4_client
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lib/tasks/session_create.rake
33 строки
879 B
Yuriy
producer
13 дек 2025, 20:11
13 дек 2025, 20:11
8e4d352
Код
Авторство
О чём код?
# lib/tasks/rabbit.rake require 'securerandom' require 'json' require_relative '../../app/services/rabbitmq_producer' namespace :rabbit do desc "Login via RabbitMQ and get JWT token" task login: :environment do producer = RabbitmqProducer.new correlation_id = SecureRandom.uuid # Сообщение message = { id: correlation_id, entity: 'sessions', version: 'v1', action: 'create', data: { attributes: { email: 'email@mail.ru', password: '12345' } }, auth: nil } puts "Message sent, waiting for response..." producer.publish('api.requests', message) response = producer.subscribe('api.responses', correlation_id: correlation_id, timeout: 10) puts "Response: #{JSON.pretty_generate(response)}" producer.close end end