private MessageState SendMessageInternal(QueueMessage msg) { try { if (msg == null) { throw new MessageException(MessageState.ArgumentsError, "QueueMessage null"); } msg.Validate(); switch (msg.MessageType)//.DistributionMode) { case MessageTypes.DirectToQueue: SendDirectToQueue(msg); break; case MessageTypes.BatchToMailer: SendBatchToQueue(msg); break; case MessageTypes.SplitToQueue: SendSplitToQueue(msg); break; } return(MessageState.Received); } catch (MessageException mex) { Netlog.ErrorFormat("QueueProxy SendMessageInternal MessageException : {0}", mex.Message); return(mex.MessageState); } catch (Exception ex) { Netlog.ErrorFormat("QueueProxy SendMessageInternal Error: {0}", ex.Message); return(MessageState.UnExpectedError); } }
public AcknowledgeStatus EnqueueMessage(string serItem) { try { QueueItem item = QueueItem.Deserialize(serItem); if (item == null) { throw new MessageException(AcknowledgeStatus.BadRequest, "QueueItem.Deserialize failed"); } EnqueueMessage(item); return(AcknowledgeStatus.Received); } catch (MessageException mex) { Netlog.ErrorFormat("RemoteService MailerService EnqueueMessage error: {0}", mex.Message); return(mex.AcknowledgeStatus); } catch (Exception ex) { Netlog.ErrorFormat("RemoteService MailerService Error: {0}", ex.Message); Netlog.ErrorFormat("RemoteService MailerService ErrorStackTrace: {0}", ex.StackTrace); return(AcknowledgeStatus.UnExpectedError); } }
public void Stop() { //Netcell.Log.Debug("Stop Mailer_Manager"); try { keepAlive = false; if (m_disterbuters != null) { foreach (string key in m_disterbuters.Keys) { m_disterbuters[key].Stop(); Thread.Sleep(10); } } if (threadManager != null) { threadManager.Abort();; threadManager = null; } } catch (Exception ex) { Netlog.ErrorFormat("Stop Mailer_Manager:{0}", ex.Message); } }
public static void DeleteFile(string filename) { if (File.Exists(filename)) { try { File.Delete(filename); } catch (Exception ex) { Netlog.ErrorFormat("Error DeleteFile: {0}, {1} ", filename, ex.Message); } } }
public static void MoveFile(string source, string dest) { try { if (File.Exists(dest)) { File.Delete(dest); } File.Move(source, dest); } catch (Exception ex) { Netlog.ErrorFormat("Error MoveFile: {0}, {1} ", dest, ex.Message); } }
void QueueStart() { try { //Log.Debug("MailerManager start..."); //ManagerConfig config = Config.CreateManagerConfig();// new ManagerConfig(); queue_manager = new Queue_Manager(); queue_manager.Start();//McLock.Lock.ValidateLock(), true); host_queueStart(); //Log.Debug("MailerManager started!"); } catch (Exception ex) { Netlog.ErrorFormat("QueueService error:{0},Trace:{1}", ex.Message, ex.StackTrace); } }
public AcknowledgeStatus EnqueueItem(QueueItem item) { try { EnqueueMessage(item); return(AcknowledgeStatus.Received); } catch (MessageException mex) { Netlog.ErrorFormat("RemoteService MailerService EnqueueItem error: {0}", mex.Message); return(mex.AcknowledgeStatus); } catch (Exception ex) { Netlog.ErrorFormat("RemoteService MailerService Error: {0}", ex.Message); return(AcknowledgeStatus.UnExpectedError); } }
public AcknowledgeStatus EnqueueItem(QueueItem item, string queueName) { try { RemoteQueueServer.QueueManager[queueName].Enqueue(item); return(AcknowledgeStatus.Received); } catch (MessageException mex) { Netlog.ErrorFormat("RemoteService QueueService EnqueueItem error: {0}", mex.Message); return(mex.AcknowledgeStatus); } catch (Exception ex) { Netlog.ErrorFormat("RemoteService QueueService Error: {0}", ex.Message); return(AcknowledgeStatus.UnExpectedError); } }
public void Stop() { //Netcell.Log.Debug("Stop Mailer_Manager"); try { keepAlive = false; if (threadManager != null) { threadManager.Abort();; threadManager = null; } } catch (Exception ex) { Netlog.ErrorFormat("Stop Queue_Manager:{0}", ex.Message); } }
public MessageState SendMessage(Stream stream) { try { QueueMessage msg = new QueueMessage(stream); if (msg == null) { throw new MessageException(MessageState.MessageError, "QueueMessage.Deserialize failed"); } return(SendMessageInternal(msg)); } catch (MessageException mex) { Netlog.ErrorFormat("QueueProxy SendMessage MessageException: {0}", mex.Message); return(mex.MessageState); } catch (Exception ex) { Netlog.ErrorFormat("QueueProxy SendMessage Error: {0}", ex.Message); return(MessageState.UnExpectedError); } }
public AcknowledgeStatus Enqueue(MessageQueue msg) { try { QueueItem item = QueueItem.Deserialize(msg.SerilaizedValue); if (item == null) { throw new MessageException(AcknowledgeStatus.BadRequest, "QueueItem.Deserialize failed"); } RemoteQueueServer.QueueManager[msg.QueueName].Enqueue(item); return(AcknowledgeStatus.Received); } catch (MessageException mex) { Netlog.ErrorFormat("RemoteService QueueService EnqueueItem error: {0}", mex.Message); return(mex.AcknowledgeStatus); } catch (Exception ex) { Netlog.ErrorFormat("RemoteService QueueService Error: {0}", ex.Message); return(AcknowledgeStatus.UnExpectedError); } }
///// <summary> ///// Dequeue message from queue, using sync methods. ///// </summary> ///// <returns></returns> //public IQueueItem Dequeue() //{ // try // { // CurrentItem = null; // //EnsureSync(); // m_fileMessage.DequeueFirstItem() // if (m_fileMessage.CanQueue()) // { // //Thread.Sleep(1000); // //string folder = m_fileMessage.GetFirstBatchFolder(FileOrderType); // //if (folder != null) // //{ // // if (m_fileMessage.DequeueFolder(FileOrderType,MaxItemsPerSession) > 0) // // { // // return CurrentItem;//.GetMessage(); // // } // //} // } // else // { // Thread.Sleep(1000); // } // } // catch (Exception ex) // { // Netlog.ErrorFormat("error FolderQueue.Dequeue :{0}, Trace:{1} ", ex.Message, ex.StackTrace); // } // return null; //} /// <summary> /// Dequeue message from queue with specified item id , using sync methods. /// </summary> /// <param name="identifier"></param> /// <returns></returns> public IQueueItem DequeueItem(string identifier) { try { CurrentItem = null; //EnsureOperations(); EnsureRecieve(); if (m_fileMessage.CanQueue()) { string filename = m_fileMessage.GetQueueFilename(identifier); var item = m_fileMessage.DequeueFile(filename); if (item == null) { return(null); } return(item);//.GetMessage(); //if (m_fileMessage.DequeueFile(filename) > 0) //{ // if (CurrentItem != null) // { // return CurrentItem.GetMessage(); // } //} } else { Thread.Sleep(1000); } } catch (Exception ex) { Netlog.ErrorFormat("error FolderQueue.Dequeue :{0}, Trace:{1} ", ex.Message, ex.StackTrace); } return(null); }