public Task SendAsync(string correlationId, DataAvailableNotificationDto dataAvailableNotificationDto) { ArgumentNullException.ThrowIfNull(correlationId, nameof(correlationId)); ArgumentNullException.ThrowIfNull(dataAvailableNotificationDto, nameof(dataAvailableNotificationDto)); var sender = _messageBusFactory.GetSenderClient(_messageHubConfig.DataAvailableQueue); #pragma warning disable CS0618 var recipient = dataAvailableNotificationDto.Recipient is LegacyActorIdDto legacyActorIdDto #pragma warning restore CS0618 ? legacyActorIdDto.LegacyValue : dataAvailableNotificationDto.Recipient.Value.ToString(); var contract = new DataAvailableNotificationContract { UUID = dataAvailableNotificationDto.Uuid.ToString(), Recipient = recipient, MessageType = dataAvailableNotificationDto.MessageType.Value, Origin = dataAvailableNotificationDto.Origin.ToString(), SupportsBundling = dataAvailableNotificationDto.SupportsBundling, RelativeWeight = dataAvailableNotificationDto.RelativeWeight, DocumentType = dataAvailableNotificationDto.DocumentType }; var messageId = Guid.NewGuid().ToString(); var message = new ServiceBusMessage(new BinaryData(contract.ToByteArray())) { MessageId = messageId, PartitionKey = dataAvailableNotificationDto.Origin.ToString() } .AddDataAvailableIntegrationEvents(correlationId); return(sender.PublishMessageAsync <ServiceBusMessage>(message)); }
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())); }
public Task SendAsync(string correlationId, DequeueNotificationDto dequeueNotificationDto, DomainOrigin domainOrigin) { ArgumentNullException.ThrowIfNull(dequeueNotificationDto, nameof(dequeueNotificationDto)); var queueName = GetQueueName(domainOrigin); var serviceBusSender = _messageBusFactory.GetSenderClient(queueName); #pragma warning disable CS0618 var marketOperator = dequeueNotificationDto.MarketOperator is LegacyActorIdDto legacyActorIdDto #pragma warning restore CS0618 ? legacyActorIdDto.LegacyValue : dequeueNotificationDto.MarketOperator.Value.ToString(); var contract = new DequeueContract { DataAvailableNotificationReferenceId = dequeueNotificationDto.DataAvailableNotificationReferenceId, MarketOperator = marketOperator }; var dequeueMessage = new ServiceBusMessage(new BinaryData(contract.ToByteArray())) .AddDequeueIntegrationEvents(correlationId); return(serviceBusSender.PublishMessageAsync <ServiceBusMessage>(dequeueMessage)); }