private PublishRequest BuildPublishRequest(Message message) { var messageToSend = _serialisationRegister.Serialise(message, serializeForSnsPublishing: true); var messageType = _messageSubjectProvider.GetSubjectForType(message.GetType()); var messageAttributeValues = message.MessageAttributes?.ToDictionary( source => source.Key, source => { if (source.Value == null) { return(null); } return(new MessageAttributeValue { StringValue = source.Value.StringValue, BinaryValue = source.Value.BinaryValue != null ? new MemoryStream(source.Value.BinaryValue, false) : null, DataType = source.Value.DataType }); }); return(new PublishRequest { TopicArn = Arn, Subject = messageType, Message = messageToSend, MessageAttributes = messageAttributeValues }); }
protected override void Given() { _serialisationRegister.Serialise(Arg.Any <Message>(), Arg.Is(true)).Returns(Message); _sns.FindTopic("TopicName").Returns(new Topic { TopicArn = TopicArn }); }
protected override void Given() { _sqs.GetQueueUrlAsync(Arg.Any <string>()).Returns(new GetQueueUrlResponse { QueueUrl = Url }); _sqs.GetQueueAttributesAsync(Arg.Any <GetQueueAttributesRequest>()).Returns(new GetQueueAttributesResponse()); _serialisationRegister.Serialise(_message, false).Returns("serialized_contents"); }
private PublishRequest BuildPublishRequest(Message message) { var messageToSend = _serialisationRegister.Serialise(message, serializeForSnsPublishing: true); var messageType = message.GetType().Name; return(new PublishRequest { TopicArn = Arn, Subject = messageType, Message = messageToSend }); }
public void Publish(Message message) { var messageToSend = _serialisationRegister.Serialise(message, serializeForSnsPublishing: true); var messageType = message.GetType().Name; Client.Publish(new PublishRequest { Subject = messageType, Message = messageToSend, TopicArn = Arn }); EventLog.Info("Published message: '{0}' with content {1}", messageType, messageToSend); }
public async Task PublishAsync(Message message) { var messageToSend = _serialisationRegister.Serialise(message, serializeForSnsPublishing: true); var messageType = message.GetType().Name; var request = new PublishRequest { TopicArn = Arn, Subject = messageType, Message = messageToSend }; try { await Client.PublishAsync(request); _eventLog.LogInformation($"Published message: '{messageType}' with content {messageToSend}"); } catch (Exception ex) { throw new PublishException( $"Failed to publish message to SNS. TopicArn: {request.TopicArn} Subject: {request.Subject} Message: {request.Message}", ex); } }
public string GetMessageInContext(Message message) => _serialisationRegister.Serialise(message, serializeForSnsPublishing: false);