public void Receive(object item) { MessageConfig msgConfig = item as MessageConfig; if (msgConfig == null) { return; } try { InitQueue(msgConfig); while (true) { SqlMessageQueue sqlMsgQueue = null; try { var sqlMessageQueue = new MSMessageQueueExtension <SqlMessageQueue>(msgConfig.ManagerMessagePath, msgConfig.ManagerThreadTimeOut); sqlMsgQueue = sqlMessageQueue.Receive(); PutQueue(sqlMsgQueue); } catch (TimeoutException outEx) { Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds)); } catch (Exception ex) { LogHelper.WriteException(string.Format("Receive messages error: content: {0}; parameters:{1}", (sqlMsgQueue != null ? sqlMsgQueue.commandText : string.Empty), GetMessagQueueParamterString(sqlMsgQueue)), ex); Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds)); } } } catch (Exception error) { LogHelper.WriteException(string.Format("Queue {0} error:", msgConfig.ManagerMessagePath), error); } }
public void Receive(object item) { MessageConfig msgConfig = item as MessageConfig; if (msgConfig == null) return; try { InitQueue(msgConfig); while (true) { SqlMessageQueue sqlMsgQueue = null; try { var sqlMessageQueue = new MSMessageQueueExtension<SqlMessageQueue>(msgConfig.ManagerMessagePath, msgConfig.ManagerThreadTimeOut); sqlMsgQueue = sqlMessageQueue.Receive(); PutQueue(sqlMsgQueue); } catch (TimeoutException outEx) { Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds)); } catch (Exception ex) { LogHelper.WriteException(string.Format("Receive messages error: content: {0}; parameters:{1}", (sqlMsgQueue != null ? sqlMsgQueue.commandText : string.Empty), GetMessagQueueParamterString(sqlMsgQueue)), ex); Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds)); } } } catch (Exception error) { LogHelper.WriteException(string.Format("Queue {0} error:", msgConfig.ManagerMessagePath), error); } }