public void ProcessMessage(IMessage message) { if (stop) { return; } try { resetEvent.Reset(); if (stop) { resetEvent.Set(); return; } using (var tx = transactionScopeFactory.CreateNewTransactionScope(transactionSettings, session)) { tx.MessageAccepted(message); TransportMessage transportMessage = null; Exception exception = null; try { transportMessage = activeMqMessageMapper.CreateTransportMessage(message); if (TryProcessMessage(transportMessage)) { tx.Complete(); } } catch (Exception e) { exception = e; } finally { EndProcessMessage(transportMessage, exception); } } } finally { resetEvent.Set(); } }