public RFProcessingResult Process(RFInstruction i, IRFProcessingContext processingContext) { try { if (i is RFProcessInstruction) { var pi = i as RFProcessInstruction; if (_processes.ContainsKey(pi.ProcessName)) { var process = _processes[pi.ProcessName]; return(ProcessInstruction(process, i as RFProcessInstruction, processingContext)); } else { var msg = String.Format("Process {0} referenced by instruction {1} not found in engine configuration.", pi.ProcessName, i); Log.Error(this, msg); return(RFProcessingResult.Error(new string[] { msg }, false)); } } } catch (Exception ex) { Log.Exception(this, ex, "Exception processing instruction {0}", i); return(RFProcessingResult.Error(new string[] { ex.Message }, false)); } return(new RFProcessingResult()); }
private void ProcessInstructionThread(RFWorkQueueItem i) { try { // To make transaction work we'd have to use a single SQL connection to do all reads and writes /* using (var ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions * { * IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, * Timeout = TimeSpan.FromSeconds(30) * }))*/ { Log.Debug(this, "Started thread to process instruction {0}", i.Item as RFProcessInstruction); var sink = new RFBufferingSink(); // create thread-local manager to buffer events and instructions, then send them back in bulk RFProcessingResult result = null; try { result = _context.Engine.Process(i.Item as RFInstruction, _context.GetProcessingContext(i.ProcessingKey, sink, sink, null)); } catch (Exception ex) { Log.Exception(this, ex, "Exception Thread processing queue item ", i); result = RFProcessingResult.Error(new string[] { ex.Message }, ex is DbException || ex is TimeoutException); } // send result and all buffered events/instructions to external event manager (since // we can't guarantee delivery order with MSMQ) _eventSink.RaiseEvent(this, new RFProcessingFinishedEvent(i, result, sink.GetItems()), i.ProcessingKey); //ts.Complete(); } } catch (Exception ex) { Log.Exception(this, ex, "Exception Thread processing queue item ", i); } }
private void ProcessInstructionThread(RFWorkQueueItem i) { try { Log.Debug(this, "Started thread to process instruction {0}", i.Item as RFProcessInstruction); var result = _context.Engine.Process(i.Item as RFInstruction, _context.GetProcessingContext(i.ProcessingKey, _instructionSink, _eventSink, this)); _eventSink.RaiseEvent(this, new RFProcessingFinishedEvent(i, result, null), i.ProcessingKey); // we do not store work queue items in-proc } catch (Exception ex) { Log.Exception(this, ex, "Exception Thread processing queue item ", i); _eventSink.RaiseEvent(this, new RFProcessingFinishedEvent(i, RFProcessingResult.Error(new string[] { ex.Message }, false), null), i.ProcessingKey); } }