public Task SendAsync(DataBundleResponseDto dataBundleResponseDto) { ArgumentNullException.ThrowIfNull(dataBundleResponseDto, nameof(dataBundleResponseDto)); var sessionId = dataBundleResponseDto.RequestId.ToString(); var contractBytes = _responseBundleParser.Parse(dataBundleResponseDto); var serviceBusReplyMessage = new ServiceBusMessage(contractBytes) { SessionId = sessionId, }.AddDataBundleResponseIntegrationEvents(dataBundleResponseDto.RequestIdempotencyId); var sender = _messageBusFactory.GetSenderClient(_messageHubConfig.DomainReplyQueue); return(sender.PublishMessageAsync <ServiceBusMessage>(serviceBusReplyMessage)); }
public async Task <DataBundleResponseDto?> SendAsync( DataBundleRequestDto dataBundleRequestDto, DomainOrigin domainOrigin) { ArgumentNullException.ThrowIfNull(dataBundleRequestDto, nameof(dataBundleRequestDto)); var bytes = _requestBundleParser.Parse(dataBundleRequestDto); var sessionId = dataBundleRequestDto.RequestId.ToString(); var replyQueue = GetReplyQueueName(domainOrigin); var targetQueue = GetQueueName(domainOrigin); var serviceBusMessage = new ServiceBusMessage(bytes) { SessionId = sessionId, ReplyToSessionId = sessionId, ReplyTo = replyQueue, TimeToLive = _peekRequestConfig.PeekTimeout ?? _defaultTimeout }.AddRequestDataBundleIntegrationEvents(dataBundleRequestDto.IdempotencyId); var serviceBusClient = _messageBusFactory.GetSenderClient(targetQueue); await serviceBusClient .PublishMessageAsync <ServiceBusMessage>(serviceBusMessage) .ConfigureAwait(false); await using var receiverMessageBus = await _messageBusFactory .GetSessionReceiverClientAsync(replyQueue, sessionId) .ConfigureAwait(false); var response = await receiverMessageBus .ReceiveMessageAsync <ServiceBusMessage>(_peekRequestConfig.PeekTimeout ?? _defaultTimeout) .ConfigureAwait(false); if (response == null) { return(null); } return(_responseBundleParser.Parse(response.Body.ToArray())); }