using Common.Logging; using Quartz; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using Apache.NMS; using Apache.NMS.ActiveMQ; namespace SiaSun.LMS.WinService { public class Job_Base { public static SiaSun.LMS.Common.ActiveMsg _ActiveMsg = new SiaSun.LMS.Common.ActiveMsg(); #region 数据持久层实例 public static SiaSun.LMS.Persistence.P_IO_CONTROL _P_IO_CONTROL = new SiaSun.LMS.Persistence.P_IO_CONTROL(); public static SiaSun.LMS.Persistence.P_IO_CONTROL_APPLY _P_IO_CONTROL_APPLY = new SiaSun.LMS.Persistence.P_IO_CONTROL_APPLY(); #endregion public bool SendMsg(string sUrl ,string sTopic,string sMsg ,out string sResult) { bool bResult = true; sResult = string.Empty; IConnectionFactory factory = new ConnectionFactory(sUrl); try { using (IConnection connection = factory.CreateConnection()) { //Create the Session using (ISession session = connection.CreateSession()) { //Create the Producer for the topic/queue IMessageProducer prod = session.CreateProducer( new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic(sTopic)); //Send Messages ITextMessage msg = prod.CreateTextMessage(); msg.Text = sMsg; prod.Send(msg, Apache.NMS.MsgDeliveryMode.NonPersistent, Apache.NMS.MsgPriority.Normal, TimeSpan.MinValue); } } } catch (Exception ex) { bResult = false; sResult = ex.Message.ToString(); } finally { } return bResult; } } }