Azure Service Bus(2)
先去NuGet里安装Service Bus 组件
下面是应用,贼简单
var MethodCont = new JObject { new JProperty("vendorCode",EclpNum),//商家编码 new JProperty("waybillCode",TripNumber),//申通运单号 new JProperty("weight",TripWeight),//重量 new JProperty("volume",Volume),//体积 }; var Send = JsonConvert.SerializeObject(MethodCont); byte[] bytes = Encoding.UTF8.GetBytes(Send); MemoryStream ms = new MemoryStream(); ms.Write(bytes, 0, bytes.Length); var message = new Message(ms.ToArray()); message.Label = "xxxx"; string connectionString = ConfigurationManager.AppSettings.Get("connectionString").ToString(); string entityPath = ConfigurationManager.AppSettings.Get("entityPath").ToString(); ITopicClient topicClient = new TopicClient(connectionString, entityPath); await topicClient.SendAsync(message);
<add key="connectionString" value="Endpoint=sb://zkb.servicebus.chinacloudapi.cn/;SharedAccessKeyName=zkb.backend.m;SharedAccessKey=zkb;" /> <add key="entityPath" value="xxxx" />
上面这两个key是在Azure的控制台上生成的那个链接字符串;
人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。