MsmqTransactionWrapper GetOrCreateTransactionWrapper() { if (currentTransaction != null) { return(currentTransaction); } currentTransaction = new MsmqTransactionWrapper(); currentTransaction.Finished += () => currentTransaction = null; return(currentTransaction); }
public ReceivedTransportMessage ReceiveMessage() { var transactionWrapper = new MsmqTransactionWrapper(); try { transactionWrapper.Begin(); var message = inputQueue.Receive(TimeSpan.FromSeconds(2), transactionWrapper.MessageQueueTransaction); if (message == null) { log.Warn("Received NULL message - how weird is that?"); transactionWrapper.Commit(); return(null); } var body = message.Body; if (body == null) { log.Warn("Received message with NULL body - how weird is that?"); transactionWrapper.Commit(); return(null); } var transportMessage = (ReceivedTransportMessage)body; transactionWrapper.Commit(); return(transportMessage); } catch (MessageQueueException) { transactionWrapper.Abort(); return(null); } catch (Exception e) { log.Error(e, "An error occurred while receiving message from {0}", inputQueuePath); transactionWrapper.Abort(); return(null); } }
public TransportMessage ReceiveMessage() { var transactionWrapper = new MsmqTransactionWrapper(); try { transactionWrapper.Begin(); var message = inputQueue.Receive(TimeSpan.FromSeconds(2), transactionWrapper.MessageQueueTransaction); if (message == null) { transactionWrapper.Commit(); return null; } var body = message.Body; if (body == null) { transactionWrapper.Commit(); return null; } var transportMessage = (TransportMessage) body; transportMessage.Id = message.Id; transactionWrapper.Commit(); return transportMessage; } catch (MessageQueueException) { transactionWrapper.Abort(); return null; } catch (Exception e) { Console.WriteLine(e); transactionWrapper.Abort(); return null; } }
MsmqTransactionWrapper GetOrCreateTransactionWrapper() { if (currentTransaction != null) { return currentTransaction; } currentTransaction = new MsmqTransactionWrapper(); currentTransaction.Finished += () => currentTransaction = null; return currentTransaction; }
public ReceivedTransportMessage ReceiveMessage() { var transactionWrapper = new MsmqTransactionWrapper(); try { transactionWrapper.Begin(); var message = inputQueue.Receive(TimeSpan.FromSeconds(2), transactionWrapper.MessageQueueTransaction); if (message == null) { log.Warn("Received NULL message - how weird is that?"); transactionWrapper.Commit(); return null; } var body = message.Body; if (body == null) { log.Warn("Received message with NULL body - how weird is that?"); transactionWrapper.Commit(); return null; } var transportMessage = (ReceivedTransportMessage)body; transactionWrapper.Commit(); return transportMessage; } catch (MessageQueueException) { transactionWrapper.Abort(); return null; } catch (Exception e) { log.Error(e, "An error occurred while receiving message from {0}", inputQueuePath); transactionWrapper.Abort(); return null; } }