Exemplo n.º 1
0
 /// <summary>
 /// Sends a new message to an existing queue
 /// </summary>
 /// <param name="messageToSend">The message to send.</param>
 /// <param name="data">The additional data.</param>
 /// <returns></returns>
 /// <exception cref="DotNetWorkQueueException"></exception>
 /// <exception cref="System.Exception">Failed to insert record</exception>
 /// <exception cref="System.ApplicationException"></exception>
 public IQueueOutputMessage Send(IMessage messageToSend, IAdditionalMessageData data)
 {
     try
     {
         var id = _dataStorage.SendMessage(messageToSend, data);
         return(new QueueOutputMessage(_sentMessageFactory.Create(new MessageQueueId(id), data.CorrelationId)));
     }
     catch (Exception exception)
     {
         return(new QueueOutputMessage(_sentMessageFactory.Create(null, data.CorrelationId), exception));
     }
 }
Exemplo n.º 2
0
 /// <inheritdoc />
 public Guid SendMessage(IMessage messageToSend, IAdditionalMessageData data)
 {
     using (var scope = _tracer.StartActivity("SendMessage"))
     {
         scope?.AddCommonTags(data, _connectionInformation);
         if (scope?.Context != null)
         {
             messageToSend.Inject(_tracer, scope.Context, _headers.StandardHeaders);
         }
         try
         {
             var id = _handler.SendMessage(messageToSend, data);
             if (id == Guid.Empty)
             {
                 scope?.SetStatus(Status.Error);
             }
             ;
             scope?.AddMessageIdTag(id.ToString());
             return(id);
         }
         catch (Exception e)
         {
             scope?.SetStatus(Status.Error);;
             scope?.RecordException(e);
             throw;
         }
     }
 }