private async Task sendMessages(Endpoint destination, PersistentMessage[] messages) { var sender = createSender(destination, messages); MessageBookmark[] sendHistoryBookmarks = null; sender.Success = () => sendHistoryBookmarks = success(messages); try { await sender.Send(); _logger.DebugMessage(() => new MessagesSent(messages, destination)); } catch (FailedToConnectException ex) { _logger.InfoMessage(new FailedToSend(destination, "Failed to connect", ex)); failedToConnect(messages); } catch (QueueDoesNotExistsException) { _logger.InfoMessage(new FailedToSend(destination, "Queue doesn't exist")); failedToSend(messages, true); } catch (RevertSendException) { _logger.InfoMessage(new FailedToSend(destination, "Revert was received")); revert(sendHistoryBookmarks, messages); } catch (Exception ex) { _logger.InfoMessage(new FailedToSend(destination, "Exception was thrown", ex)); failedToSend(messages); } }
private async Task sendMessages(Endpoint destination, PersistentMessage[] messages) { var sender = createSender(destination, messages); MessageBookmark[] sendHistoryBookmarks = null; sender.Success = () => sendHistoryBookmarks = success(messages); try { await sender.Send().ConfigureAwait(false); _logger.MessagesSent(messages, destination); } catch (FailedToConnectException ex) { _logger.FailedToSend(destination, "Failed to connect", ex); failedToConnect(messages); } catch (QueueDoesNotExistsException) { _logger.FailedToSend(destination, "Queue doesn't exist"); failedToSend(messages, true); } catch (RevertSendException) { _logger.FailedToSend(destination, "Revert was received"); revert(sendHistoryBookmarks, messages); } catch (TimeoutException) { try { _logger.FailedToSend(destination, "Timed out"); failedToSend(messages); } catch (EsentException) { // This will occur if the task completed as the TimeoutException was thrown, and // the message was moved to history. Swallow it to prevent unobserved task exceptions. } } catch (Exception ex) { _logger.FailedToSend(destination, "Exception was thrown", ex); failedToSend(messages); } }
public void EnqueueDirectlyTo(ITransaction transaction, string queue, string subqueue, MessagePayload payload, MessageId id = null) { var message = new PersistentMessage { Data = payload.Data, Headers = payload.Headers, Id = id ?? new MessageId { SourceInstanceId = _queueStorage.Id, MessageIdentifier = GuidCombGenerator.Generate() }, Queue = queue, SentAt = DateTime.Now, SubQueue = subqueue, Status = MessageStatus.EnqueueWait }; _queueStorage.Global(actions => { var queueActions = actions.GetQueue(queue); var bookmark = queueActions.Enqueue(message); actions.RegisterUpdateToReverse(transaction.Id, bookmark, MessageStatus.EnqueueWait, subqueue); }); _logger.QueuedForReceive(message); lock (_newMessageArrivedLock) { Monitor.PulseAll(_newMessageArrivedLock); } }
public MessageBookmark MoveTo(string subQueue, PersistentMessage message) { _messages.MoveTo(message.Bookmark); var id = _messages.GetMessageId(); var bookmark = _messages.Update(() => { _messages.ForColumnType<IntColumn>().Set("status", (int)MessageStatus.SubqueueChanged); _messages.ForColumnType<StringColumn>().Set("subqueue", subQueue); }); bookmark.QueueName = _queueName; _logger.Debug("Moving message {0} to subqueue {1}", id, _queueName); return bookmark; }
private void addMessageRow(TableRowTag row, PersistentMessage message) { row.Cell(message.Id.ToString()); row.Cell(message.Status.ToString()); row.Cell(message.SentAt.ToString()); var cell = row.Cell(); var list = new HtmlTag("ul", cell); foreach (var key in message.Headers.AllKeys) { list.Add("li").Text("{0}&{1}".ToFormat(key, message.Headers[key])); } }
private Sender createSender(Endpoint destination, PersistentMessage[] messages) { return new Sender(_logger) { Connected = () => _choke.SuccessfullyConnected(), Destination = destination, Messages = messages, }; }