/// <summary> /// 單向寫入資料 /// </summary> /// <returns></returns> public ActionResult Contact() { ViewBag.Message = "Your contact page."; var MQAdapter = new MQProducerFacade(); if (!MQAdapter.IsConnected()) { //MQAdapter.Init(); MQAdapter.Connect(); } string message = SetMessage(); string queueName = $"MQ{DateTime.Now.ToString("yyyyMMdd")}.TaskQueue"; MQAdapter.Publish(queueName, message); return(View()); }
/// <summary> /// 雙向服務,寫入資料後,又取得資料 /// 需搭配Consumer(),Consumer需先點開,讓另一個執行序去跑 /// </summary> /// <returns></returns> public ActionResult About() { var MQAdapter = new MQProducerFacade(); if (!MQAdapter.IsConnected()) { MQAdapter.Connect(); } string message = SetMessage(); string queueName = $"MQ{DateTime.Now.ToString("yyyyMMdd")}.TaskQueue"; MQAdapter.Publish(queueName, message); //接收回傳 string replyQueue = $"MQ{DateTime.Now.ToString("yyyyMMdd")}.ReplyMessage"; ViewBag.Message = MQAdapter.GetReturnMessage(replyQueue); return(View()); }
public string PushNotification([FromBody] AccountArgs account) { IMQProducerFacade MQAdapter = new MQProducerFacade(); if (!MQAdapter.IsConnected()) { MQAdapter.Connect(); } string queueName = $"MQ{DateTime.Now.ToString("yyyyMMdd")}.TaskQueue"; if (!string.IsNullOrEmpty(account.MessageContent)) { MQAdapter.Publish(queueName, SetMessage(account.MessageContent)); } else { return("Please Enter MessageContent"); } return("Sent Success"); }