Azure Service Bus(2)

先去NuGet里安装Service Bus 组件

Azure Service Bus(2)

 

 

 下面是应用,贼简单

 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的控制台上生成的那个链接字符串;

 

上一篇:ASP.NET Core教程:ASP.NET Core中使用Redis缓存


下一篇:c – 指向开始的减法或减量随机访问迭代器