当前位置: 首页 > news >正文

电商网站首页布局dw做网站首页怎么做

电商网站首页布局,dw做网站首页怎么做,网站空间续费,网页设计图片界面1.首先我们来讲解一下消息队列的作用 比如说我们的订单系统#xff0c;再客户订单生成了以后#xff0c;可能会有 快递系统#xff0c;通知系统#xff0c;和打印系统需要用到当前订单的详细内容 所以这个时候常规的操作是在A里面通过代码调用B#xff0c;C #xff…1.首先我们来讲解一下消息队列的作用 比如说我们的订单系统再客户订单生成了以后可能会有 快递系统通知系统和打印系统需要用到当前订单的详细内容 所以这个时候常规的操作是在A里面通过代码调用BC  D系统的接口来通知他们有新订单了 如果此时有个E系统呢 那我们的做法可能只能在A系统中增加代码来通知E系统但是如果后期我们的E系统又不要了呢岂不是我们又要在A系统中去除掉这一部分代码所以说这样的代码冗余就很高对后期的性能也很有影响因为系统A中通知BCD系统还要判断 B,C,D返回值中是否成功如果没有成功还要子再次请求这样系统性能就非常的低下 所以说我们使用了MQ来解决这个问题 我们A系统秩序通知MQ系统 后面的BCD要信息的话直接找MQ系统调用就行 接下来我这里讲解下如何把MQ集成到.net 项目中 生产者端: using Aliyun.MQ; using Aliyun.MQ.Model; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks;namespace CSDNSign.Controllers {[Route(api/[controller])][ApiController]public class MQController : ControllerBase{readonly IFreeSql _sql;private readonly ILoggerMQController _logger;private const string _endpoint *************;// AccessKey ID阿里云身份验证在阿里云服务器管理控制台创建。private const string _accessKeyId *************;// AccessKey Secret阿里云身份验证在阿里云服务器管理控制台创建。private const string _secretAccessKey *************;// 所属的Topic。private const string _topicName xsw;// Topic所属实例ID默认实例为空。private const string _instanceId *************;private static MQClient _client new Aliyun.MQ.MQClient(_accessKeyId, _secretAccessKey, _endpoint);static MQProducer producer _client.GetProducer(_instanceId, _topicName);/// summary/// /// /summary/// param namesql/param/// param namelogger/parampublic MQController(IFreeSql sql, ILoggerMQController logger){_sql sql;_logger logger;}#region /// summary/// /// /summary/// param namejson/param/// param namekey/param/// param nametag/param/// returns/returns[HttpPost][Route(TestMQ)]public string TestMQ(string json, string key, string tag){try{TopicMessage sendMsg new TopicMessage(json);// 设置属性。sendMsg.PutProperty(a, a);// 设置Key。sendMsg.MessageKey key;TopicMessage result producer.PublishMessage(sendMsg);return JsonConvert.SerializeObject(result) ;}catch (Exception ex){return ex.Message.ToString();}}#endregion} }其中的endpoint可以在阿里云中接入点中查看 由于我们用的http的方式接受所以我们复制下面的地址 消费者端: using Aliyun.MQ; using Aliyun.MQ.Model; using Aliyun.MQ.Model.Exp; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Permissions; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace WPFTest {/// summary/// Interaction logic for MainWindow.xaml/// /summarypublic partial class MainWindow : Window{private const string _endpoint ********;// AccessKey ID阿里云身份验证在阿里云服务器管理控制台创建。private const string _accessKeyId *****;// AccessKey Secret阿里云身份验证在阿里云服务器管理控制台创建。private const string _secretAccessKey *****;// 所属的Topic。private const string _topicName *****;// Topic所属实例ID默认实例为空。private const string _instanceId *******;private const string _groupId *********;private static MQClient _client new Aliyun.MQ.MQClient(_accessKeyId, _secretAccessKey, _endpoint);static MQConsumer consumer _client.GetConsumer(_instanceId, _topicName, _groupId, null);private Thread thread;public MainWindow(){InitializeComponent();this.button_Stop.IsEnabled false;}private void button_Click(object sender, RoutedEventArgs e){thread new Thread(new ThreadStart(TaskStart));thread.IsBackground true;thread.Start();this.button_get.IsEnabled false;this.button_Stop.IsEnabled true;}/// summary/// 开始任务/// /summaryprivate void TaskStart(){Dispatcher.Invoke(() this.textBox.Text 开始获取MQ任务 \n);// 在当前线程循环消费消息建议多开个几个线程并发消费消息。while (true){try{// 长轮询消费消息。// 长轮询表示如果Topic没有消息,则请求会在服务端挂起3s3s内如果有消息可以消费则立即返回客户端。ListMessage messages null;try{messages consumer.ConsumeMessage(3, // 一次最多消费3条最多可设置为16条。3 // 长轮询时间3秒最多可设置为30秒。);}catch (Exception exp1){if (exp1 is MessageNotExistException){Dispatcher.Invoke(() textBox.Text string.Format(Thread.CurrentThread.Name No new message, ((MessageNotExistException)exp1).RequestId \n));continue;}Console.WriteLine(exp1);Thread.Sleep(2000);}if (messages null){continue;}Liststring handlers new Liststring();Liststring mqmessage new Liststring();Console.WriteLine(Thread.CurrentThread.Name Receive Messages:);// 处理业务逻辑。foreach (Message message in messages){Console.WriteLine(message);Console.WriteLine(Property a is: message.GetProperty(a));handlers.Add(message.ReceiptHandle);mqmessage.Add(message.Body);}// Message.nextConsumeTime前若不确认消息消费成功则消息会被重复消费。// 消息句柄有时间戳同一条消息每次消费拿到的都不一样。try{consumer.AckMessage(handlers);Console.WriteLine(Ack message success:);foreach (string handle in mqmessage){Dispatcher.Invoke(() textBox.Text handle \n);}Console.WriteLine();return;}catch (Exception exp2){// 某些消息的句柄可能超时会导致消息消费状态确认不成功。if (exp2 is AckMessageException){AckMessageException ackExp (AckMessageException)exp2;Console.WriteLine(Ack message fail, RequestId: ackExp.RequestId);foreach (AckMessageErrorItem errorItem in ackExp.ErrorItems){Dispatcher.Invoke(() textBox.Text string.Format(\tErrorHandle: errorItem.ReceiptHandle ,ErrorCode: errorItem.ErrorCode ,ErrorMsg: errorItem.ErrorMessage));}}}}catch (Exception ex){Console.WriteLine(ex);Thread.Sleep(2000);}}}private void button_Clean_Click(object sender, RoutedEventArgs e){this.textBox.Text ;}private void button_Stop_Click(object sender, RoutedEventArgs e){this.button_get.IsEnabled true;this.button_Stop.IsEnabled false;thread.Interrupt();// Wait for newThread to end.//thread.Join();}} }最后项目效果如下所示:
http://www.yutouwan.com/news/502958/

相关文章:

  • 做app网站公司哪家好优秀网站推荐
  • 做推广便宜的网站淮北网站建设制作
  • 柳市做网站的公司企业信息平台查询
  • 山西太原建设厅官方网站wordpress页面关联目录
  • 仪表东莞网站建设沧州外贸公司
  • 个人网站谢谢网站 全屏幻灯片
  • 社区网站模板建设部网站公民服务
  • 济南网站设计哪家好百度推广费用预算表
  • 让别人做网站需要注意什么随州做网站
  • 猪八戒 网站开发支付wordpress网页无法运作
  • 网站建设龙头股2023网页游戏大全
  • 重庆网站设计总部南充网站建设与维护
  • 集团网站建设 中企动力北京病例最新消息今天
  • 做室内效果图网站在建项目信息查询平台
  • 山东宏福建设集团有限公司网站连云港网站制作公司哪家好
  • 哈尔滨网站建设外包公司深圳网络营销的公司哪家好
  • 免费在线网站模板旅游景点网站建设设计说明
  • 公司网站建设一年多少钱营销方案网站
  • 购买云服务器后怎么做网站seo网站设计网页单页设计
  • 新手学做网站1核2g 做网站
  • 网站安全狗卸载卸载不掉哪些网站有中文域名
  • 网站开发服务外包合同五个常见的电子商务网站网址
  • 北京中交建设工程咨询有限公司网站网站建设需求模板
  • 农村网站建设调查报告手机单页网站生成系统
  • 武夷山网站推广服务在过没wordpress火吗
  • 泉州网站建设方案开发手机可以做app的软件
  • seo网站培训优化怎么做wordpress模板后门
  • 网站开发动态wordpress top主题
  • 佛山网站优化效果学计算机去哪个职业学校
  • 网站搭建软件有哪些优秀的响应式网站模板