示例#1
0
 public bool Publish <TMessage>([DisallowNull] TMessage message, PublishOptions?options = null)
 {
     if (message == null)
     {
         throw new ArgumentNullException(nameof(message));
     }
     return(_channel.Publish(message, options));
 }
示例#2
0
        /// <summary>
        /// Sends the ticket
        /// </summary>
        /// <param name="sdkTicket">The <see cref="ISdkTicket"/> to be send</param>
        public void SendTicket(ISdkTicket sdkTicket)
        {
            var msg = GetByteMsg(sdkTicket);

            if (string.IsNullOrEmpty(sdkTicket.CorrelationId))
            {
                _feedLog.Warn($"Ticket: {sdkTicket.TicketId} is missing CorrelationId.");
            }

            var ticketCI = new TicketCacheItem(TicketHelper.GetTicketTypeFromTicket(sdkTicket), sdkTicket.TicketId, sdkTicket.CorrelationId, _mtsChannelSettings.ReplyToRoutingKey, null, sdkTicket);

            // we clear cache, since already sent ticket with the same ticketId are obsolete (example: sending ticket, ticketAck, ticketCancel, ticketCancelAck)
            if (_ticketCache.TryRemove(sdkTicket.TicketId, out _))
            {
                _executionLog.Debug($"Removed already sent ticket from cache {sdkTicket.TicketId}");
            }

            _ticketCache.TryAdd(sdkTicket.TicketId, ticketCI);
            _publisherChannel.Publish(sdkTicket.TicketId, msg: msg, routingKey: _mtsChannelSettings.PublishRoutingKey, correlationId: sdkTicket.CorrelationId, replyRoutingKey: _mtsChannelSettings.ReplyToRoutingKey);
        }