"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[3867],{9759:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>x,frontMatter:()=>t,metadata:()=>a,toc:()=>u});var s=r(5893),c=r(1151),i=r(4996),o=r(510);const t={id:"event-bus",title:"22. \u4e8b\u4ef6\u603b\u7ebf",sidebar_label:"22. \u4e8b\u4ef6\u603b\u7ebf (EventBus)"},l=void 0,a={id:"event-bus",title:"22. \u4e8b\u4ef6\u603b\u7ebf",description:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7",source:"@site/docs/event-bus.mdx",sourceDirName:".",slug:"/event-bus",permalink:"/docs/event-bus",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/event-bus.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1698369938,formattedLastUpdatedAt:"Oct 27, 2023",frontMatter:{id:"event-bus",title:"22. \u4e8b\u4ef6\u603b\u7ebf",sidebar_label:"22. \u4e8b\u4ef6\u603b\u7ebf (EventBus)"},sidebar:"docs",previous:{title:"21. \u5168\u7403\u5316\u548c\u672c\u5730\u5316\uff08\u591a\u8bed\u8a00\uff09",permalink:"/docs/local-language"},next:{title:"23. JSON \u5e8f\u5217\u5316",permalink:"/docs/json-serialization"}},d={},u=[{value:"22.1 \u5173\u4e8e\u4e8b\u4ef6\u603b\u7ebf",id:"221-\u5173\u4e8e\u4e8b\u4ef6\u603b\u7ebf",level:2},{value:"22.2 \u5feb\u901f\u5165\u95e8",id:"222-\u5feb\u901f\u5165\u95e8",level:2},{value:"22.2.1 \u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f",id:"2221-\u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f",level:3},{value:"22.2.2 \u53d1\u5e03\u4e8b\u4ef6\u6d88\u606f",id:"2222-\u53d1\u5e03\u4e8b\u4ef6\u6d88\u606f",level:3},{value:"22.2.3 \u6ce8\u518c\u4e8b\u4ef6\u670d\u52a1",id:"2223-\u6ce8\u518c\u4e8b\u4ef6\u670d\u52a1",level:3},{value:"22.2.4 \u8fd0\u884c\u9879\u76ee",id:"2224-\u8fd0\u884c\u9879\u76ee",level:3},{value:"22.3 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90",id:"223-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90",level:2},{value:"22.4 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668",id:"224-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668",level:2},{value:"22.4.1 Redis
\u81ea\u5b9a\u4e49\u6307\u5357",id:"2241-redis-\u81ea\u5b9a\u4e49\u6307\u5357",level:3},{value:"22.4.2 RabbitMQ
\u81ea\u5b9a\u4e49\u6307\u5357",id:"2242-rabbitmq-\u81ea\u5b9a\u4e49\u6307\u5357",level:3},{value:"22.4.3 Kafka
\u81ea\u5b9a\u4e49\u6307\u5357",id:"2243-kafka-\u81ea\u5b9a\u4e49\u6307\u5357",level:3},{value:"22.5 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u53d1\u5e03\u8005",id:"225-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u53d1\u5e03\u8005",level:2},{value:"22.6 \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u76d1\u89c6\u5668",id:"226-\u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u76d1\u89c6\u5668",level:2},{value:"22.7 \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u5668",id:"227-\u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u5668",level:2},{value:"22.8 \u4f7f\u7528\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1",id:"228-\u4f7f\u7528\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1",level:2},{value:"22.9 \u8ba2\u9605\u6267\u884c\u4efb\u52a1\u610f\u5916\u5f02\u5e38",id:"229-\u8ba2\u9605\u6267\u884c\u4efb\u52a1\u610f\u5916\u5f02\u5e38",level:2},{value:"22.10 \u4e8b\u4ef6\u603b\u7ebf\u5de5\u5382",id:"2210-\u4e8b\u4ef6\u603b\u7ebf\u5de5\u5382",level:2},{value:"22.11 MessageCenter
\u9759\u6001\u7c7b",id:"2211-messagecenter-\u9759\u6001\u7c7b",level:2},{value:"22.12 \u914d\u7f6e\u91cd\u8bd5\u5931\u8d25\u56de\u8c03",id:"2212-\u914d\u7f6e\u91cd\u8bd5\u5931\u8d25\u56de\u8c03",level:2},{value:"22.13 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u4e0d\u53ef\u7528\u65f6\u56de\u9000",id:"2213-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u4e0d\u53ef\u7528\u65f6\u56de\u9000",level:2},{value:"22.14 EventBusOptionsBuilder
\u914d\u7f6e",id:"2214-eventbusoptionsbuilder-\u914d\u7f6e",level:2},{value:"22.15 \u5173\u4e8e\u9ad8\u9891\u6d88\u606f\u5904\u7406\u65b9\u5f0f",id:"2215-\u5173\u4e8e\u9ad8\u9891\u6d88\u606f\u5904\u7406\u65b9\u5f0f",level:2},{value:"22.16 IIS \u90e8\u7f72\u56de\u6536\u8bbe\u7f6e",id:"2216-iis-\u90e8\u7f72\u56de\u6536\u8bbe\u7f6e",level:2},{value:"22.17 \u4f7f\u7528\u7b2c\u4e09\u65b9\u4e8b\u4ef6\u603b\u7ebf CAP
\u793a\u4f8b",id:"2217-\u4f7f\u7528\u7b2c\u4e09\u65b9\u4e8b\u4ef6\u603b\u7ebf-cap-\u793a\u4f8b",level:2},{value:"22.18 \u5728 WinForm/WPF
\u4e2d\u4f7f\u7528",id:"2218-\u5728-winformwpf-\u4e2d\u4f7f\u7528",level:2},{value:"22.19 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"2219-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",del:"del",h2:"h2",h3:"h3",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,c.a)(),...e.components},{Details:r}=n;return r||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7"}),(0,s.jsx)("div",{children:(0,s.jsx)("div",{children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u65b0\u7279\u6027"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf\u652f\u6301\u7b80\u5355\u7684 ",(0,s.jsx)(n.code,{children:"Order"})," \u7f16\u6392\u89c4\u5219 ",(0,s.jsx)("sup",{children:"4.8.0"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/833c0d4d069bca5f5304aa21cb32c7f902c20c69",children:"833c0d4"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:".ReplaceStorerOrFallback"})," \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u65b9\u6cd5\uff0c\u53ef\u5728\u81ea\u5b9a\u4e49\u521d\u59cb\u5931\u8d25\u65f6\u56de\u9000\u5230\u9ed8\u8ba4\u503c ",(0,s.jsx)("sup",{children:"4.7.6"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I602NU",children:"#I602NU"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf\u6a21\u5757\u91cd\u8bd5\u5931\u8d25\u540e\u652f\u6301\u56de\u8c03 ",(0,s.jsx)("sup",{children:"4.6.1"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5UVMV",children:"#I5UVMV"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"LogEnabled"})," \u914d\u7f6e\uff0c\u53ef\u63a7\u5236\u662f\u5426\u8f93\u51fa\u670d\u52a1\u65e5\u5fd7 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5QLY5",children:"#I5QLY5"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," ",(0,s.jsxs)(n.strong,{children:["\u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"MessageCenter"})," \u9759\u6001\u7c7b\uff0c\u89e3\u51b3\u4ece ",(0,s.jsx)(n.code,{children:"Fur v1.x"})," \u7248\u672c\u5347\u7ea7\u95ee\u9898 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/a29fc7cf63a3ea41b1617a6ad98a701a243e24f8",children:"a29fc7c"})]})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," ",(0,s.jsx)(n.strong,{children:"\u4e8b\u4ef6\u603b\u7ebf\u5de5\u5382\uff0c\u652f\u6301\u8fd0\u884c\u65f6\u52a8\u6001\u6dfb\u52a0\u8ba2\u9605\u7a0b\u5e8f\u548c\u79fb\u9664\u8ba2\u9605\u7a0b\u5e8f"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5NNQX",children:"#I5NNQX"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," ",(0,s.jsxs)(n.strong,{children:["\u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"[EventSubscribe]"})," \u4e8b\u4ef6 ",(0,s.jsx)(n.code,{children:"Id"})," \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d"]})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5NNQX",children:"#I5NNQX"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," ",(0,s.jsxs)(n.strong,{children:["\u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"[EventSubscribe]"})," \u652f\u6301\u5c40\u90e8\u5931\u8d25\u91cd\u8bd5\u914d\u7f6e"]})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5NNQX",children:"#I5NNQX"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"options.AddSubscriber(Type)"})," \u91cd\u8f7d ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/blob/424460780b630e1c71de4db84ad8fd14e33a09f5/framework/Furion.Pure/EventBus/Builders/EventBusOptionsBuilder.cs",children:"42446078"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"UseUtcTimestamp"})," \u9009\u9879\u914d\u7f6e\uff0c\u53ef\u9009\u62e9\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"DateTime.UtcNow"})," \u8fd8\u662f ",(0,s.jsx)(n.code,{children:"DateTime.Now"}),"\uff0c\u9ed8\u8ba4\u662f ",(0,s.jsx)(n.code,{children:"DateTime.Now"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5JSEU",children:"#I5JSEU"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf\u6a21\u5757\u4e8b\u4ef6 ",(0,s.jsx)(n.code,{children:"Id"})," \u652f\u6301\u679a\u4e3e\u7c7b\u578b ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/2f328aa8213c8efe7a8480116985573cc6b7fce6",children:"2f328aa"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf\u6a21\u5757\u53d1\u5e03\u8005 ",(0,s.jsx)(n.code,{children:"PublishAsync"})," \u548c ",(0,s.jsx)(n.code,{children:"PublishDelayAsync"})," \u91cd\u8f7d ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/2f328aa8213c8efe7a8480116985573cc6b7fce6",children:"2f328aa"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u65b0\u589e"})," \u4e8b\u4ef6\u603b\u7ebf\u6a21\u5757\u62d3\u5c55\u65b9\u6cd5\uff1a",(0,s.jsx)(n.code,{children:"Enum.ParseToString()"})," \u548c ",(0,s.jsx)(n.code,{children:"String.ParseToEnum()"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/2f328aa8213c8efe7a8480116985573cc6b7fce6",children:"2f328aa"})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u7a81\u7834\u6027\u53d8\u5316"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u8c03\u6574"})," ",(0,s.jsxs)(n.strong,{children:["\u4e8b\u4ef6\u603b\u7ebf\u89e6\u53d1\u5904\u7406\u7a0b\u5e8f\u7684\u903b\u8f91\uff0c\u7531\u8fc7\u53bb\u7684 ",(0,s.jsx)(n.code,{children:"foreach"})," \u6539\u4e3a ",(0,s.jsx)(n.code,{children:"Parallel.ForEach"}),"\uff0c\u541e\u5410\u91cf\u63d0\u5347\u8fd1 4 \u500d"]})," ",(0,s.jsx)("sup",{children:"4.6.4"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/7384c9c3efb94883421379828565e61870f1640c",children:"7384c9c"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u8c03\u6574"})," ",(0,s.jsxs)(n.strong,{children:["\u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"IEventBusFactory"})," \u4e8b\u4ef6\u5de5\u5382\u65b9\u6cd5 ",(0,s.jsx)(n.code,{children:"AddSubscriber -> Subscribe"}),"\uff0c",(0,s.jsx)(n.code,{children:"RemoveSubscriber -> Unsubscribe"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/a29fc7cf63a3ea41b1617a6ad98a701a243e24f8",children:"a29fc7c"})]})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u95ee\u9898\u4fee\u590d"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u4fee\u590d"})," \u8d85\u9ad8\u9891\u7387\u4e0b\u53d1\u9001\u4e8b\u4ef6\u603b\u7ebf\u6d88\u606f\uff0c\u4f46\u662f ",(0,s.jsx)(n.code,{children:"GC"})," \u6765\u4e0d\u53ca\u56de\u6536\u5bfc\u81f4\u5185\u5b58\u548c ",(0,s.jsx)(n.code,{children:"CPU"})," \u7206\u6389\u95ee\u9898 ",(0,s.jsx)("sup",{children:"4.6.8"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/dbc7935618ff60d7f41d82c0d49042cd189e58b9",children:"dbc7935"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u4fee\u590d"})," \u57fa\u4e8e ",(0,s.jsx)(n.code,{children:"Redis"})," \u91cd\u5199\u4e8b\u4ef6\u5b58\u50a8\u5668\u5e8f\u5217\u5316 ",(0,s.jsx)(n.code,{children:"IEventSource"})," \u5b9e\u4f8b\u5f02\u5e38\u95ee\u9898 ",(0,s.jsx)("sup",{children:"4.4.7"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/3e45020eca5948d18d5cb405a665aae44088fd20",children:"3e45020"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u4fee\u590d"})," \u4e8b\u4ef6\u603b\u7ebf\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"Channel"})," \u7ba1\u9053\u521d\u59cb\u5316\u65f6\u673a\u8fc7\u665a\u95ee\u9898\uff0c\u89e3\u51b3\u90e8\u5206\u7b2c\u4e09\u65b9\u4f9d\u8d56\u4f7f\u7528\u95ee\u9898 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5MM3O",children:"#I5MM3O"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u4fee\u590d"})," \u4e8b\u4ef6\u603b\u7ebf\u9ed8\u8ba4\u5f00\u542f\u6a21\u7cca\u5339\u914d\uff08\u6b63\u5219\u8868\u8fbe\u5f0f\uff09\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u8ba2\u9605 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5NVOP",children:"#I5NVOP"})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u5176\u4ed6\u8c03\u6574"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u8c03\u6574"})," \u4e8b\u4ef6\u603b\u7ebf\u9ed8\u8ba4\u65e5\u5fd7\u7c7b\u540d\u4e3a ",(0,s.jsx)(n.code,{children:"System.Logging.EventBusService"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5QLY5",children:"#I5QLY5"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(o.Z,{children:"\u8c03\u6574"})," \u4e8b\u4ef6\u603b\u7ebf\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"Channel"})," \u7ba1\u9053\u521d\u59cb\u5316\u65f6\u673a\uff0c\u89e3\u51b3\u90e8\u5206\u7b2c\u4e09\u65b9\u4f9d\u8d56\u4f7f\u7528\u95ee\u9898 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I5MM3O",children:"#I5MM3O"})]}),"\n"]}),"\n"]}),"\n"]})})})]}),"\n",(0,s.jsx)(n.admonition,{title:"v2.20 \u4ee5\u4e0b\u7248\u672c\u8bf4\u660e",type:"warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsxs)(n.strong,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Furion v2.20+"})," \u7248\u672c\u91c7\u7528 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Jaina",children:"Jaina"})," \u4e8b\u4ef6\u603b\u7ebf\u66ff\u6362\u539f\u6709\u7684 ",(0,s.jsx)(n.code,{children:"EventBus"})]}),"\uff0c",(0,s.jsx)(n.a,{href:"/docs/event-bus-old",children:"\u67e5\u770b\u65e7\u6587\u6863"})]})}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 2.20.0 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"221-\u5173\u4e8e\u4e8b\u4ef6\u603b\u7ebf",children:"22.1 \u5173\u4e8e\u4e8b\u4ef6\u603b\u7ebf"}),"\n",(0,s.jsx)(n.p,{children:"\u4e8b\u4ef6\u603b\u7ebf\u662f\u5bf9\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\u7684\u4e00\u79cd\u5b9e\u73b0\u3002\u5b83\u662f\u4e00\u79cd\u96c6\u4e2d\u5f0f\u4e8b\u4ef6\u5904\u7406\u673a\u5236\uff0c\u5141\u8bb8\u4e0d\u540c\u7684\u7ec4\u4ef6\u4e4b\u95f4\u8fdb\u884c\u5f7c\u6b64\u901a\u4fe1\u800c\u53c8\u4e0d\u9700\u8981\u76f8\u4e92\u4f9d\u8d56\uff0c\u8fbe\u5230\u4e00\u79cd\u89e3\u8026\u7684\u76ee\u7684\u3002"}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/ebs.png")}),"\n",(0,s.jsx)(n.h2,{id:"222-\u5feb\u901f\u5165\u95e8",children:"22.2 \u5feb\u901f\u5165\u95e8"}),"\n",(0,s.jsx)(n.h3,{id:"2221-\u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f",children:"22.2.1 \u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f"}),"\n",(0,s.jsxs)(n.p,{children:["\u5b9a\u4e49\u4e8b\u4ef6\u8ba2\u9605\u8005 ",(0,s.jsx)(n.code,{children:"ToDoEventSubscriber"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,10-11,19-21,28-30,32,36-38,44-48,54-56}",children:'// \u5b9e\u73b0 IEventSubscriber \u63a5\u53e3\r\npublic class ToDoEventSubscriber : IEventSubscriber\r\n{\r\n private readonly ILogger _logger;\r\n public ToDoEventSubscriber(ILogger logger)\r\n {\r\n _logger = logger;\r\n }\r\n\r\n [EventSubscribe("ToDo:Create")]\r\n public async Task CreateToDo(EventHandlerExecutingContext context)\r\n {\r\n var todo = context.Source;\r\n _logger.LogInformation("\u521b\u5efa\u4e00\u4e2a ToDo\uff1a{Name}", todo.Payload);\r\n await Task.CompletedTask;\r\n }\r\n\r\n // \u652f\u6301\u591a\u4e2a\r\n [EventSubscribe("ToDo:Create")]\r\n [EventSubscribe("ToDo:Update")]\r\n public async Task CreateOrUpdateToDo(EventHandlerExecutingContext context)\r\n {\r\n var todo = context.Source;\r\n _logger.LogInformation("\u521b\u5efa\u6216\u66f4\u65b0\u4e00\u4e2a ToDo\uff1a{Name}", todo.Payload);\r\n await Task.CompletedTask;\r\n }\r\n\r\n // \u652f\u6301\u679a\u4e3e\u7c7b\u578b\uff0cv3.4.3+ \u7248\u672c\u652f\u6301\r\n [EventSubscribe(YourEnum.Some)]\r\n public async Task EnumHandler(EventHandlerExecutingContext context)\r\n {\r\n var eventEnum = context.Source.EventId.ParseToEnum(); // \u5c06\u4e8b\u4ef6 Id \u8f6c\u6362\u6210\u679a\u4e3e\u5bf9\u8c61\r\n await Task.CompletedTask;\r\n }\r\n\r\n // \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\uff0c4.2.10+ \u7248\u672c\u652f\u6301\r\n [EventSubscribe("(^1[3456789][0-9]{9}$)|((^[0-9]{3,4}\\\\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\\\\([0-9]{3,4}\\\\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$))", FuzzyMatch = true)]\r\n public async Task RegexHandler(EventHandlerExecutingContext context)\r\n {\r\n var eventId = context.Source.EventId;\r\n await Task.CompletedTask;\r\n }\r\n\r\n // \u652f\u6301\u591a\u79cd\u5f02\u5e38\u91cd\u8bd5\u914d\u7f6e\uff0cFurion 4.2.10+ \u7248\u672c\u652f\u6301\r\n [EventSubscribe("test:error", NumRetries = 3)]\r\n [EventSubscribe("test:error", NumRetries = 3, RetryTimeout = 1000)] // \u91cd\u8bd5\u95f4\u9694\u65f6\u95f4\r\n [EventSubscribe("test:error", NumRetries = 3, ExceptionTypes = new[] { typeof(ArgumentException) })] // \u7279\u5b9a\u7c7b\u578b\u5f02\u5e38\u624d\u91cd\u8bd5\r\n public async Task ExceptionHandler(EventHandlerExecutingContext context)\r\n {\r\n var eventId = context.Source.EventId;\r\n await Task.CompletedTask;\r\n }\r\n\r\n // \u652f\u6301\u7b80\u5355 Order \u7f16\u6392\uff0cFurion 4.8.0+ \u7248\u672c\u652f\u6301\r\n [EventSubscribe("test:order", Order = 1)]\r\n public async Task ExceptionHandler(EventHandlerExecutingContext context)\r\n {\r\n var eventId = context.Source.EventId;\r\n await Task.CompletedTask;\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2222-\u53d1\u5e03\u4e8b\u4ef6\u6d88\u606f",children:"22.2.2 \u53d1\u5e03\u4e8b\u4ef6\u6d88\u606f"}),"\n",(0,s.jsxs)(n.p,{children:["\u521b\u5efa\u63a7\u5236\u5668 ",(0,s.jsx)(n.code,{children:"ToDoController"}),"\uff0c\u4f9d\u8d56\u6ce8\u5165 ",(0,s.jsx)(n.code,{children:"IEventPublisher"})," \u670d\u52a1\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {5,13-15,21-25}",children:'public class ToDoController : ControllerBase\r\n{\r\n // \u4f9d\u8d56\u6ce8\u5165\u4e8b\u4ef6\u53d1\u5e03\u8005 IEventPublisher\r\n private readonly IEventPublisher _eventPublisher;\r\n public ToDoController(IEventPublisher eventPublisher)\r\n {\r\n _eventPublisher = eventPublisher;\r\n }\r\n\r\n // \u53d1\u5e03 ToDo:Create \u6d88\u606f\r\n public async Task CreateDoTo(string name)\r\n {\r\n await _eventPublisher.PublishAsync(new ChannelEventSource("ToDo:Create", name));\r\n // \u4e5f\u53ef\u4ee5\u5ef6\u8fdf\u53d1\u5e03\uff0c\u6bd4\u5982\u5ef6\u8fdf 3s\r\n await _eventPublisher.PublishDelayAsync(new ChannelEventSource("ToDo:Create", name), 3000);\r\n }\r\n\r\n // v3.4.3+ \u7248\u672c\u652f\u6301\u53d1\u9001\u6d88\u606f\u7b80\u5316\r\n public async Task CreateDoTo(string name)\r\n {\r\n await _eventPublisher.PublishAsync("ToDo:Create", name);\r\n // \u4e5f\u53ef\u4ee5\u5ef6\u8fdf\u53d1\u5e03\uff0c\u6bd4\u5982\u5ef6\u8fdf 3s\r\n await _eventPublisher.PublishDelayAsync("ToDo:Create", 3000, name);\r\n // \u4e5f\u652f\u6301\u679a\u4e3e\r\n await _eventPublisher.PublishAsync(YourEnum.Some);\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2223-\u6ce8\u518c\u4e8b\u4ef6\u670d\u52a1",children:"22.2.3 \u6ce8\u518c\u4e8b\u4ef6\u670d\u52a1"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Startup.cs"})," \u6ce8\u518c ",(0,s.jsx)(n.code,{children:"EventBus"})," \u670d\u52a1\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,5}",children:"// \u6ce8\u518c EventBus \u670d\u52a1\r\nservices.AddEventBus(builder =>\r\n{\r\n // \u6ce8\u518c ToDo \u4e8b\u4ef6\u8ba2\u9605\u8005\r\n builder.AddSubscriber();\r\n\r\n // \u901a\u8fc7\u7c7b\u578b\u6ce8\u518c\uff0cFurion 4.2.1+ \u7248\u672c\r\n builder.AddSubscriber(typeof(ToDoEventSubscriber));\r\n\r\n // \u6279\u91cf\u6ce8\u518c\u4e8b\u4ef6\u8ba2\u9605\u8005\r\n builder.AddSubscribers(ass1, ass2, ....);\r\n});\n"})}),"\n",(0,s.jsxs)(n.admonition,{title:"\u61d2\u4eba\u63d0\u9192",type:"tip",children:[(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Furion"})," \u4e2d\u53ef\u4ee5\u4e0d\u7528\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"builder.AddSubscriber()"})," \u65b9\u5f0f\u4e00\u4e00\u6ce8\u518c\uff0c\u53ea\u9700\u8981\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"ISingleton"})," \u63a5\u53e3\u5373\u53ef\uff0c\u5982\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1}",children:"public class ToDoEventSubscriber : IEventSubscriber, ISingleton\r\n{\r\n}\n"})}),(0,s.jsxs)(n.p,{children:["\u8fd9\u6837\u5c31\u65e0\u9700\u5199 ",(0,s.jsx)(n.del,{children:(0,s.jsx)(n.code,{children:"builder.AddSubscriber();"})})," \u4ee3\u7801\u4e86\uff0c\u53ea\u9700\u4fdd\u7559 ",(0,s.jsx)(n.code,{children:"services.AddEventBus()"})," \u670d\u52a1\u5373\u53ef\u3002"]})]}),"\n",(0,s.jsx)(n.h3,{id:"2224-\u8fd0\u884c\u9879\u76ee",children:"22.2.4 \u8fd0\u884c\u9879\u76ee"}),"\n",(0,s.jsx)(n.p,{children:"\u8fd0\u884c\u9879\u76ee\u5e76\u89e6\u53d1\u4e8b\u4ef6\u53d1\u5e03\u63a5\u53e3\u6216\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"info: Jaina.Samples.ToDoEventSubscriber[0]\r\n \u521b\u5efa\u4e00\u4e2a ToDo\uff1aJaina\n"})}),"\n",(0,s.jsx)(n.h2,{id:"223-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90",children:"22.3 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"IEventSource"})," \u4f5c\u4e3a\u6d88\u606f\u8f7d\u4f53\uff0c\u4efb\u4f55\u5b9e\u73b0\u8be5\u63a5\u53e3\u7684\u7c7b\u90fd\u53ef\u4ee5\u5145\u5f53\u6d88\u606f\u8f7d\u4f53\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u9700\u81ea\u5b9a\u4e49\uff0c\u53ea\u9700\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"IEventSource"})," \u63a5\u53e3\u5373\u53ef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3,14,19,24,29,35-37}",children:"public class ToDoEventSource : IEventSource\r\n{\r\n public ToDoEventSource()\r\n {\r\n }\r\n\r\n public ToDoEventSource(string eventId, string todoName)\r\n {\r\n EventId = eventId;\r\n ToDoName = todoName;\r\n }\r\n\r\n // \u81ea\u5b9a\u4e49\u5c5e\u6027\r\n public string ToDoName { get; set; }\r\n\r\n /// \r\n /// \u4e8b\u4ef6 Id\r\n /// \r\n public string EventId { get; set; }\r\n\r\n /// \r\n /// \u4e8b\u4ef6\u627f\u8f7d\uff08\u643a\u5e26\uff09\u6570\u636e\r\n /// \r\n public object Payload { get; set; }\r\n\r\n /// \r\n /// \u4e8b\u4ef6\u521b\u5efa\u65f6\u95f4\r\n /// \r\n public DateTime CreatedTime { get; set; } = DateTime.UtcNow;\r\n\r\n /// \r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \r\n /// \u7528\u4e8e\u53d6\u6d88\u672c\u6b21\u6d88\u606f\u5904\u7406\r\n [Newtonsoft.Json.JsonIgnore]\r\n [System.Text.Json.Serialization.JsonIgnore]\r\n public CancellationToken CancellationToken { get; set; }\r\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'await _eventPublisher.PublishAsync(new ToDoEventSource ("ToDo:Create", "\u6211\u7684 ToDo Name"));\n'})}),"\n",(0,s.jsx)(n.h2,{id:"224-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668",children:"22.4 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u9ed8\u8ba4\u91c7\u7528 ",(0,s.jsx)(n.code,{children:"Channel"})," \u4f5c\u4e3a\u4e8b\u4ef6\u6e90 ",(0,s.jsx)(n.code,{children:"IEventSource"})," \u5b58\u50a8\u5668\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6d88\u606f\u961f\u5217\u7ec4\u4ef6\u8fdb\u884c\u66ff\u6362\uff0c\u5982 ",(0,s.jsx)(n.code,{children:"Kafka\u3001RabbitMQ\u3001ActiveMQ"})," \u7b49\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u90e8\u5206\u6570\u636e\u5e93 ",(0,s.jsx)(n.code,{children:"Redis\u3001SQL Server\u3001MySql"})," \u5b9e\u73b0\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u9700\u81ea\u5b9a\u4e49\uff0c\u53ea\u9700\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"IEventSourceStorer"})," \u63a5\u53e3\u5373\u53ef\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"2241-redis-\u81ea\u5b9a\u4e49\u6307\u5357",children:["22.4.1 ",(0,s.jsx)(n.code,{children:"Redis"})," \u81ea\u5b9a\u4e49\u6307\u5357"]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:[(0,s.jsx)(n.code,{children:"Windows"})," \u7248\u672c ",(0,s.jsx)(n.code,{children:"Redis"})," \u5b89\u88c5\u5305\u4e0b\u8f7d"]}),(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://github.com/tporadowski/redis",children:"https://github.com/tporadowski/redis"})})]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["1. \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Redis"})," \u62d3\u5c55\u5305"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"Install-Package Microsoft.Extensions.Caching.StackExchangeRedis\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"StackExchange.Redis"})," \u5305\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["2. \u521b\u5efa ",(0,s.jsx)(n.code,{children:"RedisEventSourceStorer"})," \u81ea\u5b9a\u4e49\u5b58\u50a8\u5668"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {11,34,49-59,77-90,101-102,110}",children:'using Furion.EventBus;\r\nusing StackExchange.Redis;\r\nusing System;\r\nusing System.Text.Json;\r\nusing System.Threading;\r\nusing System.Threading.Channels;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Furion.Core;\r\n\r\npublic sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable\r\n{\r\n /// \r\n /// \u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\r\n /// \r\n private readonly Channel _channel;\r\n\r\n /// \r\n /// Redis \u8fde\u63a5\u5bf9\u8c61\r\n /// \r\n private readonly ConnectionMultiplexer _connectionMultiplexer;\r\n\r\n /// \r\n /// \u8def\u7531\u952e\r\n /// \r\n private readonly string _routeKey;\r\n\r\n /// \r\n /// \u6784\u9020\u51fd\u6570\r\n /// \r\n /// Redis \u8fde\u63a5\u5bf9\u8c61\r\n /// \u8def\u7531\u952e\r\n /// \u5b58\u50a8\u5668\u6700\u591a\u80fd\u591f\u5904\u7406\u591a\u5c11\u6d88\u606f\uff0c\u8d85\u8fc7\u8be5\u5bb9\u91cf\u8fdb\u5165\u7b49\u5f85\u5199\u5165\r\n public RedisEventSourceStorer(ConnectionMultiplexer connectionMultiplexer, string routeKey, int capacity)\r\n {\r\n // \u914d\u7f6e\u901a\u9053\uff0c\u8bbe\u7f6e\u8d85\u51fa\u9ed8\u8ba4\u5bb9\u91cf\u540e\u8fdb\u5165\u7b49\u5f85\r\n var boundedChannelOptions = new BoundedChannelOptions(capacity)\r\n {\r\n FullMode = BoundedChannelFullMode.Wait\r\n };\r\n\r\n // \u521b\u5efa\u6709\u9650\u5bb9\u91cf\u901a\u9053\r\n _channel = Channel.CreateBounded(boundedChannelOptions);\r\n\r\n _connectionMultiplexer = connectionMultiplexer;\r\n _routeKey = routeKey;\r\n\r\n // \u83b7\u53d6\u4e00\u4e2a\u8ba2\u9605\u5bf9\u8c61\r\n var subscriber = connectionMultiplexer.GetSubscriber();\r\n\r\n // \u8ba2\u9605\u6d88\u606f\r\n subscriber.Subscribe(routeKey, (channel, data) =>\r\n {\r\n // \u8f6c\u6362\u4e3a IEventSource\uff0c\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u559c\u6b22\u7684\u5e8f\u5217\u5316\u5de5\u5177\uff0c\u5982\u679c\u81ea\u5b9a\u4e49\u4e86 EventSource\uff0c\u6ce8\u610f\u5c5e\u6027\u662f\u53ef\u8bfb\u53ef\u5199\r\n var eventSource = JsonSerializer.Deserialize(data.ToString());\r\n\r\n // \u5199\u5165\u5185\u5b58\u7ba1\u9053\u5b58\u50a8\u5668\r\n _channel.Writer.WriteAsync(eventSource);\r\n });\r\n }\r\n\r\n /// \r\n /// \u5c06\u4e8b\u4ef6\u6e90\u5199\u5165\u5b58\u50a8\u5668\r\n /// \r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \r\n public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)\r\n {\r\n // \u7a7a\u68c0\u67e5\r\n if (eventSource == default)\r\n {\r\n throw new ArgumentNullException(nameof(eventSource));\r\n }\r\n\r\n // \u8fd9\u91cc\u5224\u65ad\u662f\u5426\u662f ChannelEventSource \u6216\u8005 \u81ea\u5b9a\u4e49\u7684 EventSource\r\n if (eventSource is ChannelEventSource source)\r\n {\r\n // \u5e8f\u5217\u5316\uff0c\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u559c\u6b22\u7684\u5e8f\u5217\u5316\u5de5\u5177\r\n var data = JsonSerializer.Serialize(source);\r\n\r\n // \u83b7\u53d6\u4e00\u4e2a\u8ba2\u9605\u5bf9\u8c61\r\n var subscriber = _connectionMultiplexer.GetSubscriber();\r\n await subscriber.PublishAsync(_routeKey, data);\r\n }\r\n else\r\n {\r\n // \u8fd9\u91cc\u5904\u7406\u52a8\u6001\u8ba2\u9605\u95ee\u9898\r\n await _channel.Writer.WriteAsync(eventSource, cancellationToken);\r\n }\r\n }\r\n\r\n /// \r\n /// \u4ece\u5b58\u50a8\u5668\u4e2d\u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n /// \r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n public async ValueTask ReadAsync(CancellationToken cancellationToken)\r\n {\r\n // \u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n var eventSource = await _channel.Reader.ReadAsync(cancellationToken);\r\n return eventSource;\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\u975e\u6258\u7ba1\u8d44\u6e90\r\n /// \r\n public void Dispose()\r\n {\r\n _connectionMultiplexer.Dispose();\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"3. \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u5b58\u50a8\u5668"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,4,7,10-13}",children:'services.AddEventBus(options =>\r\n{\r\n // \u521b\u5efa Redis \u8fde\u63a5\u5bf9\u8c61\r\n var connectionMultiplexer = ConnectionMultiplexer.Connect("localhost");\r\n\r\n // \u521b\u5efa\u9ed8\u8ba4\u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5bf9\u8c61\uff0c\u53ef\u81ea\u5b9a\u4e49\u961f\u5217\u8def\u7531key\uff0c\u6bd4\u5982\u8fd9\u91cc\u662f eventbus\r\n var redisEventSourceStorer = new RedisEventSourceStorer(connectionMultiplexer, "eventbus", 3000);\r\n\r\n // \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u603b\u7ebf\u5b58\u50a8\u5668\r\n options.ReplaceStorer(serviceProvider =>\r\n {\r\n return redisEventSourceStorer;\r\n });\r\n});\n'})}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:["\u5173\u4e8e ",(0,s.jsx)(n.code,{children:"StackExchange.Redis"})," \u8d85\u65f6\u95ee\u9898"]}),(0,s.jsxs)(n.p,{children:["\u5982\u9047\u5230 ",(0,s.jsx)(n.code,{children:"StackExchange.Redis"})," \u8d85\u65f6\uff08Timeout\uff09\u95ee\u9898\uff0c\u53ef\u7f16\u8f91\u542f\u52a8\u5c42\u7684 ",(0,s.jsx)(n.code,{children:".csproj"})," \u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {4}",children:'\r\n\r\n \r\n 50\r\n \r\n\r\n\n'})}),(0,s.jsxs)(n.p,{children:["\u5982\u679c\u4ee5\u4e0a\u914d\u7f6e\u4f9d\u7136\u5b58\u5728\u8d85\u65f6\u95ee\u9898\uff0c\u90a3\u4e48\u53ef\u4ee5\u5728 ",(0,s.jsx)(n.code,{children:"Program.cs/Startup.cs"})," \u4e2d\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"ThreadPool.SetMinThreads(200, 200);"}),"\u3002"]})]}),"\n",(0,s.jsxs)(n.h3,{id:"2242-rabbitmq-\u81ea\u5b9a\u4e49\u6307\u5357",children:["22.4.2 ",(0,s.jsx)(n.code,{children:"RabbitMQ"})," \u81ea\u5b9a\u4e49\u6307\u5357"]}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 4.3.4 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:["\u7531\u4e8e\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"RabbitMQ"})," \u4f5c\u4e3a\u4e8b\u4ef6\u603b\u7ebf\u5b58\u50a8\u5668\u7684\u6bd4\u8f83\u591a\uff0c\u6240\u4ee5\u8fd9\u91cc\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u4f7f\u7528\u4f8b\u5b50\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["1. \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"RabbitMQ.Client"})," \u62d3\u5c55\u5305"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"Install-Package RabbitMQ.Client\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["2. \u521b\u5efa ",(0,s.jsx)(n.code,{children:"RabbitMQEventSourceStorer"})," \u81ea\u5b9a\u4e49\u5b58\u50a8\u5668"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {13,41,60,66-78,99-112,122-124,130-134}",children:'using Furion.EventBus;\r\nusing RabbitMQ.Client;\r\nusing RabbitMQ.Client.Events;\r\nusing System;\r\nusing System.Text;\r\nusing System.Text.Json;\r\nusing System.Threading;\r\nusing System.Threading.Channels;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Furion.Core;\r\n\r\npublic sealed class RabbitMQEventSourceStorer : IEventSourceStorer, IDisposable\r\n{\r\n /// \r\n /// \u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\r\n /// \r\n private readonly Channel _channel;\r\n\r\n /// \r\n /// \u901a\u9053\u5bf9\u8c61\r\n /// \r\n private readonly IModel _model;\r\n\r\n /// \r\n /// \u8fde\u63a5\u5bf9\u8c61\r\n /// \r\n private readonly IConnection _connection;\r\n\r\n /// \r\n /// \u8def\u7531\u952e\r\n /// \r\n private readonly string _routeKey;\r\n\r\n /// \r\n /// \u6784\u9020\u51fd\u6570\r\n /// \r\n /// \u8fde\u63a5\u5de5\u5382\r\n /// \u8def\u7531\u952e\r\n /// \u5b58\u50a8\u5668\u6700\u591a\u80fd\u591f\u5904\u7406\u591a\u5c11\u6d88\u606f\uff0c\u8d85\u8fc7\u8be5\u5bb9\u91cf\u8fdb\u5165\u7b49\u5f85\u5199\u5165\r\n public RabbitMQEventSourceStorer(ConnectionFactory factory, string routeKey, int capacity)\r\n {\r\n // \u914d\u7f6e\u901a\u9053\uff0c\u8bbe\u7f6e\u8d85\u51fa\u9ed8\u8ba4\u5bb9\u91cf\u540e\u8fdb\u5165\u7b49\u5f85\r\n var boundedChannelOptions = new BoundedChannelOptions(capacity)\r\n {\r\n FullMode = BoundedChannelFullMode.Wait\r\n };\r\n\r\n // \u521b\u5efa\u6709\u9650\u5bb9\u91cf\u901a\u9053\r\n _channel = Channel.CreateBounded(boundedChannelOptions);\r\n\r\n // \u521b\u5efa\u8fde\u63a5\r\n _connection = factory.CreateConnection();\r\n _routeKey = routeKey;\r\n\r\n // \u521b\u5efa\u901a\u9053\r\n _model = _connection.CreateModel();\r\n\r\n // \u58f0\u660e\u8def\u7531\u961f\u5217\r\n _model.QueueDeclare(routeKey, false, false, false, null);\r\n\r\n // \u521b\u5efa\u6d88\u606f\u8ba2\u9605\u8005\r\n var consumer = new EventingBasicConsumer(_model);\r\n\r\n // \u8ba2\u9605\u6d88\u606f\u5e76\u5199\u5165\u5185\u5b58 Channel\r\n consumer.Received += (ch, ea) =>\r\n {\r\n // \u8bfb\u53d6\u539f\u59cb\u6d88\u606f\r\n var stringEventSource = Encoding.UTF8.GetString(ea.Body.ToArray());\r\n\r\n // \u8f6c\u6362\u4e3a IEventSource\uff0c\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u559c\u6b22\u7684\u5e8f\u5217\u5316\u5de5\u5177\uff0c\u5982\u679c\u81ea\u5b9a\u4e49\u4e86 EventSource\uff0c\u6ce8\u610f\u5c5e\u6027\u662f\u53ef\u8bfb\u53ef\u5199\r\n var eventSource = JsonSerializer.Deserialize(stringEventSource);\r\n\r\n // \u5199\u5165\u5185\u5b58\u7ba1\u9053\u5b58\u50a8\u5668\r\n _channel.Writer.WriteAsync(eventSource);\r\n\r\n // \u786e\u8ba4\u8be5\u6d88\u606f\u5df2\u88ab\u6d88\u8d39\r\n _model.BasicAck(ea.DeliveryTag, false);\r\n };\r\n\r\n // \u542f\u52a8\u6d88\u8d39\u8005 \u8bbe\u7f6e\u4e3a\u624b\u52a8\u5e94\u7b54\u6d88\u606f\r\n _model.BasicConsume(routeKey, false, consumer);\r\n }\r\n\r\n /// \r\n /// \u5c06\u4e8b\u4ef6\u6e90\u5199\u5165\u5b58\u50a8\u5668\r\n /// \r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \r\n public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)\r\n {\r\n // \u7a7a\u68c0\u67e5\r\n if (eventSource == default)\r\n {\r\n throw new ArgumentNullException(nameof(eventSource));\r\n }\r\n\r\n // \u8fd9\u91cc\u5224\u65ad\u662f\u5426\u662f ChannelEventSource \u6216\u8005 \u81ea\u5b9a\u4e49\u7684 EventSource\r\n if (eventSource is ChannelEventSource source)\r\n {\r\n // \u5e8f\u5217\u5316\uff0c\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u559c\u6b22\u7684\u5e8f\u5217\u5316\u5de5\u5177\r\n var data = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(source));\r\n\r\n // \u53d1\u5e03\r\n _model.BasicPublish("", _routeKey, null, data);\r\n }\r\n else\r\n {\r\n // \u8fd9\u91cc\u5904\u7406\u52a8\u6001\u8ba2\u9605\u95ee\u9898\r\n await _channel.Writer.WriteAsync(eventSource, cancellationToken);\r\n }\r\n }\r\n\r\n /// \r\n /// \u4ece\u5b58\u50a8\u5668\u4e2d\u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n /// \r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n public async ValueTask ReadAsync(CancellationToken cancellationToken)\r\n {\r\n // \u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n var eventSource = await _channel.Reader.ReadAsync(cancellationToken);\r\n return eventSource;\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\u975e\u6258\u7ba1\u8d44\u6e90\r\n /// \r\n public void Dispose()\r\n {\r\n _model.Dispose();\r\n _connection.Dispose();\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"3. \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u5b58\u50a8\u5668"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,4-8,11,14-16}",children:'services.AddEventBus(options =>\r\n{\r\n // \u521b\u5efa\u8fde\u63a5\u5de5\u5382\r\n var factory = new ConnectionFactory\r\n {\r\n UserName = "admin",\r\n Password = "q1w2e3",\r\n };\r\n\r\n // \u521b\u5efa\u9ed8\u8ba4\u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5bf9\u8c61\uff0c\u53ef\u81ea\u5b9a\u4e49\u961f\u5217\u8def\u7531key\uff0c\u6bd4\u5982\u8fd9\u91cc\u662f eventbus\r\n var rbmqEventSourceStorer = new RabbitMQEventSourceStorer(factory, "eventbus", 3000);\r\n\r\n // \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u603b\u7ebf\u5b58\u50a8\u5668\r\n options.ReplaceStorer(serviceProvider =>\r\n {\r\n return rbmqEventSourceStorer;\r\n });\r\n});\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/evs1.png")}),"\n",(0,s.jsxs)(n.h3,{id:"2243-kafka-\u81ea\u5b9a\u4e49\u6307\u5357",children:["22.4.3 ",(0,s.jsx)(n.code,{children:"Kafka"})," \u81ea\u5b9a\u4e49\u6307\u5357"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["1. \u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Confluent.Kafka"})," \u62d3\u5c55\u5305"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"Install-Package Confluent.Kafka\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["2. \u521b\u5efa ",(0,s.jsx)(n.code,{children:"EventConsumer"})," \u8ba2\u9605\u7c7b"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {10}",children:'using Confluent.Kafka;\r\n\r\nnamespace Furion.Core;\r\n\r\n/// \r\n/// Kafka \u6d88\u606f\u6269\u5c55\r\n/// \r\n/// \r\n/// \r\npublic class EventConsumer : IDisposable\r\n{\r\n private Task _consumerTask;\r\n private CancellationTokenSource _consumerCts;\r\n\r\n /// \r\n /// \u6d88\u8d39\u8005\r\n /// \r\n public IConsumer Consumer { get; }\r\n\r\n /// \r\n /// ConsumerBuilder\r\n /// \r\n public ConsumerBuilder Builder { get; set; }\r\n\r\n /// \r\n /// \u6d88\u606f\u56de\u8c03\r\n /// \r\n public event EventHandler> Received;\r\n\r\n /// \r\n /// \u5f02\u5e38\u56de\u8c03\r\n /// \r\n public event EventHandler OnConsumeException;\r\n\r\n /// \r\n /// \u6784\u9020\u51fd\u6570\r\n /// \r\n /// \r\n public EventConsumer(IEnumerable> config)\r\n {\r\n Builder = new ConsumerBuilder(config);\r\n Consumer = Builder.Build();\r\n }\r\n\r\n /// \r\n /// \u542f\u52a8\r\n /// \r\n /// \r\n public void Start()\r\n {\r\n if (Consumer.Subscription?.Any() != true)\r\n {\r\n throw new InvalidOperationException("Subscribe first using the Consumer.Subscribe() function");\r\n }\r\n if (_consumerTask != null)\r\n {\r\n return;\r\n }\r\n _consumerCts = new CancellationTokenSource();\r\n var ct = _consumerCts.Token;\r\n _consumerTask = Task.Factory.StartNew(() =>\r\n {\r\n while (!ct.IsCancellationRequested)\r\n {\r\n try\r\n {\r\n var cr = Consumer.Consume(TimeSpan.FromSeconds(1));\r\n if (cr == null) continue;\r\n Received?.Invoke(this, cr);\r\n }\r\n catch (ConsumeException e)\r\n {\r\n OnConsumeException?.Invoke(this, e);\r\n }\r\n }\r\n }, ct, TaskCreationOptions.LongRunning, System.Threading.Tasks.TaskScheduler.Default);\r\n }\r\n\r\n /// \r\n /// \u505c\u6b62\r\n /// \r\n /// \r\n public async Task Stop()\r\n {\r\n if (_consumerCts == null || _consumerTask == null) return;\r\n _consumerCts.Cancel();\r\n try\r\n {\r\n await _consumerTask;\r\n }\r\n finally\r\n {\r\n _consumerTask = null;\r\n _consumerCts = null;\r\n }\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\r\n /// \r\n public void Dispose()\r\n {\r\n Dispose(true);\r\n GC.SuppressFinalize(this);\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\r\n /// \r\n /// \r\n protected virtual void Dispose(bool disposing)\r\n {\r\n if (disposing)\r\n {\r\n if (_consumerTask != null)\r\n {\r\n Stop().Wait();\r\n }\r\n Consumer?.Dispose();\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["3. \u521b\u5efa ",(0,s.jsx)(n.code,{children:"KafkaEventSourceStore"})," \u81ea\u5b9a\u4e49\u5b58\u50a8\u5668"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {11,55-63,84-99,109-110,119-120}",children:'using Confluent.Kafka;\r\nusing Furion.EventBus;\r\nusing Newtonsoft.Json;\r\nusing System.Threading.Channels;\r\n\r\nnamespace Furion.Core;\r\n\r\n/// \r\n/// Kafka \u5b58\u50a8\u6e90\r\n/// \r\npublic class KafkaEventSourceStore : IEventSourceStorer, IDisposable\r\n{\r\n /// \r\n /// \u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\r\n /// \r\n private readonly Channel _channel;\r\n /// \r\n /// \u4e3b\u9898\r\n /// \r\n private readonly string _topic;\r\n /// \r\n /// \u6d88\u8d39\u8005\r\n /// \r\n private readonly EventConsumer _eventConsumer;\r\n /// \r\n /// \u751f\u4ea7\u8005\r\n /// \r\n private readonly IProducer _producer;\r\n\r\n /// \r\n /// \u6784\u9020\u51fd\u6570\r\n /// \r\n /// \u6d88\u8d39\u8005\u914d\u7f6e\r\n /// \u751f\u4ea7\u8005\u914d\u7f6e\r\n /// \u4e3b\u9898\r\n /// \u5b58\u50a8\u5668\u6700\u591a\u80fd\u591f\u5904\u7406\u591a\u5c11\u6d88\u606f\uff0c\u8d85\u8fc7\u8be5\u5bb9\u91cf\u8fdb\u5165\u7b49\u5f85\u5199\u5165\r\n public KafkaEventSourceStore(ConsumerConfig consumerConf, ProducerConfig producerConf, string topic, int capacity)\r\n {\r\n // \u914d\u7f6e\u901a\u9053\uff0c\u8bbe\u7f6e\u8d85\u51fa\u9ed8\u8ba4\u5bb9\u91cf\u540e\u8fdb\u5165\u7b49\u5f85\r\n var boundedChannelOptions = new BoundedChannelOptions(capacity)\r\n {\r\n FullMode = BoundedChannelFullMode.Wait\r\n };\r\n\r\n // \u521b\u5efa\u6709\u9650\u5bb9\u91cf\u901a\u9053\r\n _channel = Channel.CreateBounded(boundedChannelOptions);\r\n\r\n // \u4e3b\u9898\r\n _topic = topic;\r\n\r\n // \u521b\u5efa\u6d88\u606f\u8ba2\u9605\u8005\r\n _eventConsumer = new EventConsumer(consumerConf);\r\n _eventConsumer.Consumer.Subscribe(new[] { topic });\r\n\r\n // \u8ba2\u9605\u6d88\u606f\u5199\u5165 Channel\r\n _eventConsumer.Received += (send, cr) =>\r\n {\r\n // \u53cd\u5e8f\u5217\u5316\u6d88\u606f\r\n var eventSource = JsonConvert.DeserializeObject(cr.Message.Value);\r\n\r\n // \u5199\u5165\u5185\u5b58\u7ba1\u9053\u5b58\u50a8\u5668\r\n _channel.Writer.WriteAsync(eventSource);\r\n };\r\n\r\n // \u542f\u52a8\u6d88\u8d39\u8005\r\n _eventConsumer.Start();\r\n\r\n // \u521b\u5efa\u751f\u4ea7\u8005\r\n _producer = new ProducerBuilder(producerConf).Build();\r\n }\r\n\r\n /// \r\n /// \u5c06\u4e8b\u4ef6\u6e90\u5199\u5165\u5b58\u50a8\u5668\r\n /// \r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \r\n public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)\r\n {\r\n if (eventSource == default)\r\n {\r\n throw new ArgumentNullException(nameof(eventSource));\r\n }\r\n // \u8fd9\u91cc\u5224\u65ad\u662f\u5426\u662f ChannelEventSource \u6216\u8005 \u81ea\u5b9a\u4e49\u7684 EventSource\r\n if (eventSource is ChannelEventSource source)\r\n {\r\n // \u5e8f\u5217\u5316\r\n var data = JsonConvert.SerializeObject(source);\r\n // \u5f02\u6b65\u53d1\u5e03\r\n await _producer.ProduceAsync(_topic, new Message\r\n {\r\n Value = data\r\n }, cancellationToken);\r\n }\r\n else\r\n {\r\n // \u8fd9\u91cc\u5904\u7406\u52a8\u6001\u8ba2\u9605\u95ee\u9898\r\n await _channel.Writer.WriteAsync(eventSource, cancellationToken);\r\n }\r\n }\r\n\r\n /// \r\n /// \u4ece\u5b58\u50a8\u5668\u4e2d\u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n /// \r\n /// \u53d6\u6d88\u4efb\u52a1 Token\r\n /// \u4e8b\u4ef6\u6e90\u5bf9\u8c61\r\n public async ValueTask ReadAsync(CancellationToken cancellationToken)\r\n {\r\n // \u8bfb\u53d6\u4e00\u6761\u4e8b\u4ef6\u6e90\r\n var eventSource = await _channel.Reader.ReadAsync(cancellationToken);\r\n return eventSource;\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\u975e\u6258\u7ba1\u8d44\u6e90\r\n /// \r\n public async void Dispose()\r\n {\r\n await _eventConsumer.Stop();\r\n GC.SuppressFinalize(this);\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"4. \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u5b58\u50a8\u5668"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3-8,10-15,18,21-24}",children:'services.AddEventBus(options =>\r\n{\r\n var consumerConf = new ConsumerConfig\r\n {\r\n BootstrapServers = "xxx.xxx.xxx.xxx:9092",\r\n GroupId = "Consumer",\r\n AutoOffsetReset = AutoOffsetReset.Earliest // \u4ece\u6700\u65e9\u7684\u5f00\u59cb\u6d88\u8d39\u8d77\r\n };\r\n\r\n var producerConf = new ProducerConfig\r\n {\r\n BootstrapServers = "xxx.xxx.xxx.xxx:9092",\r\n BatchSize = 16384, // \u4fee\u6539\u6279\u6b21\u5927\u5c0f\u4e3a16K\r\n LingerMs = 20 // \u4fee\u6539\u7b49\u5f85\u65f6\u95f4\u4e3a20ms\r\n };\r\n\r\n // \u521b\u5efa\u9ed8\u8ba4\u5185\u5b58\u901a\u9053\u4e8b\u4ef6\u6e90\u5bf9\u8c61\uff0c\u53ef\u81ea\u5b9a\u4e49\u961f\u5217\u8def\u7531key\uff0c\u6bd4\u5982\u8fd9\u91cc\u662f eventbus\r\n var kafkaEventSourceStorer = new KafkaEventSourceStore(consumerConf, producerConf, "testTopic", 30000);\r\n\r\n // \u66ff\u6362\u9ed8\u8ba4\u4e8b\u4ef6\u603b\u7ebf\u5b58\u50a8\u5668\r\n options.ReplaceStorer(serviceProvider =>\r\n {\r\n return kafkaEventSourceStorer;\r\n });\r\n});\n'})}),"\n",(0,s.jsx)(n.h2,{id:"225-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u53d1\u5e03\u8005",children:"22.5 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u53d1\u5e03\u8005"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u9ed8\u8ba4\u5185\u7f6e\u57fa\u4e8e ",(0,s.jsx)(n.code,{children:"Channel"})," \u7684\u4e8b\u4ef6\u53d1\u5e03\u8005 ",(0,s.jsx)(n.code,{children:"ChannelEventPublisher"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u9700\u81ea\u5b9a\u4e49\uff0c\u53ea\u9700\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"IEventPublisher"})," \u63a5\u53e3\u5373\u53ef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,10}",children:"public class ToDoEventPublisher : IEventPublisher\r\n{\r\n private readonly IEventSourceStorer _eventSourceStorer;\r\n\r\n public ToDoEventPublisher(IEventSourceStorer eventSourceStorer)\r\n {\r\n _eventSourceStorer = eventSourceStorer;\r\n }\r\n\r\n public async Task PublishAsync(IEventSource eventSource)\r\n {\r\n await _eventSourceStorer.WriteAsync(eventSource, eventSource.CancellationToken);\r\n }\r\n\r\n // .... \u5176\u4ed6\u63a5\u53e3\u5b9e\u73b0\r\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6700\u540e\uff0c\u5728\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"EventBus"})," \u670d\u52a1\u4e2d\u66ff\u6362\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"IEventPublisher"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4}",children:"services.AddEventBus(builder =>\r\n{\r\n // \u66ff\u6362\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\r\n builder.ReplacePublisher();\r\n});\n"})}),"\n",(0,s.jsx)(n.h2,{id:"226-\u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u76d1\u89c6\u5668",children:"22.6 \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u76d1\u89c6\u5668"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"IEventHandlerMonitor"})," \u76d1\u89c6\u5668\u63a5\u53e3\uff0c\u5b9e\u73b0\u8be5\u63a5\u53e3\u53ef\u4ee5\u76d1\u89c6\u6240\u6709\u8ba2\u9605\u4e8b\u4ef6\uff0c\u5305\u62ec ",(0,s.jsx)(n.code,{children:"\u6267\u884c\u4e4b\u524d\u3001\u6267\u884c\u4e4b\u540e\uff0c\u6267\u884c\u5f02\u5e38\uff0c\u5171\u4eab\u4e0a\u4e0b\u6587\u6570\u636e"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"ToDoEventHandlerMonitor"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,9,15}",children:'public class ToDoEventHandlerMonitor : IEventHandlerMonitor\r\n{\r\n private readonly ILogger _logger;\r\n public ToDoEventHandlerMonitor(ILogger logger)\r\n {\r\n _logger = logger;\r\n }\r\n\r\n public Task OnExecutingAsync(EventHandlerExecutingContext context)\r\n {\r\n _logger.LogInformation("\u6267\u884c\u4e4b\u524d\uff1a{EventId}", context.Source.EventId);\r\n return Task.CompletedTask;\r\n }\r\n\r\n public Task OnExecutedAsync(EventHandlerExecutedContext context)\r\n {\r\n _logger.LogInformation("\u6267\u884c\u4e4b\u540e\uff1a{EventId}", context.Source.EventId);\r\n\r\n if (context.Exception != null)\r\n {\r\n _logger.LogError(context.Exception, "\u6267\u884c\u51fa\u9519\u5566\uff1a{EventId}", context.Source.EventId);\r\n }\r\n\r\n return Task.CompletedTask;\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u6700\u540e\uff0c\u5728\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"EventBus"})," \u670d\u52a1\u4e2d\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"ToDoEventHandlerMonitor"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4}",children:"services.AddEventBus(builder =>\r\n{\r\n // \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u76d1\u89c6\u5668\r\n builder.AddMonitor();\r\n});\n"})}),"\n",(0,s.jsx)(n.h2,{id:"227-\u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u5668",children:"22.7 \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u5668"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"IEventHandlerExecutor"})," \u6267\u884c\u5668\u63a5\u53e3\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u6267\u884c\u7b56\u7565\uff0c\u5982 ",(0,s.jsx)(n.code,{children:"\u8d85\u65f6\u63a7\u5236\uff0c\u5931\u8d25\u91cd\u8bd5\u3001\u7194\u65ad\u7b49\u7b49"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"RetryEventHandlerExecutor"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3}",children:"public class RetryEventHandlerExecutor : IEventHandlerExecutor\r\n{\r\n public async Task ExecuteAsync(EventHandlerExecutingContext context, Func handler)\r\n {\r\n // \u5982\u679c\u6267\u884c\u5931\u8d25\uff0c\u6bcf\u9694 1s \u91cd\u8bd5\uff0c\u6700\u591a\u4e09\u6b21\r\n await Retry.InvokeAsync(async () => {\r\n await handler(context);\r\n }, 3, 1000);\r\n }\r\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6700\u540e\uff0c\u5728\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"EventBus"})," \u670d\u52a1\u4e2d\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"RetryEventHandlerExecutor"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4}",children:"services.AddEventBus(builder =>\r\n{\r\n // \u6dfb\u52a0\u4e8b\u4ef6\u6267\u884c\u5668\r\n builder.AddExecutor();\r\n});\n"})}),"\n",(0,s.jsx)(n.h2,{id:"228-\u4f7f\u7528\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1",children:"22.8 \u4f7f\u7528\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Furion"})," \u4e2d\uff0c ",(0,s.jsx)(n.code,{children:"Event Bus"})," \u6240\u6709\u670d\u52a1\u5747\u6ce8\u518c\u4e3a\u5355\u4f8b\uff0c\u5982\u9700\u4f7f\u7528\u4f5c\u7528\u57df\u670d\u52a1\uff08\u5355\u4f8b\u670d\u52a1\u53ef\u76f4\u63a5\u6ce8\u5165\uff09\uff0c\u53ef\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165 ",(0,s.jsx)(n.code,{children:"IServiceScopeFactory"})," \u5b9e\u4f8b\u5e76\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"CreateScope()"})," \u521b\u5efa\u4e00\u4e2a\u4f5c\u7528\u57df\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {5,8,10,13,18-22}",children:'public class ToDoEventSubscriber : IEventSubscriber\r\n{\r\n private readonly ILogger _logger;\r\n\r\n public ToDoEventSubscriber(IServiceScopeFactory scopeFactory // \u5355\u4f8b\u670d\u52a1\u53ef\u4ee5\u76f4\u63a5\u6ce8\u5165\r\n , ILogger logger) // \u5355\u4f8b\u670d\u52a1\u53ef\u4ee5\u76f4\u63a5\u6ce8\u5165\r\n {\r\n ScopeFactory = scopeFactory;\r\n _logger = logger;\r\n // \u907f\u514d\u5728\u8fd9\u91cc\u89e3\u6790\u975e\u5355\u4f8b\u670d\u52a1\r\n }\r\n\r\n public IServiceScopeFactory ScopeFactory { get; }\r\n\r\n [EventSubscribe("ToDo:Create")]\r\n public async Task CreateToDo(EventHandlerExecutingContext context)\r\n {\r\n // \u521b\u5efa\u65b0\u7684\u4f5c\u7528\u57df\r\n using var scope = ScopeFactory.CreateScope();\r\n\r\n // \u89e3\u6790\u670d\u52a1\r\n var scopedProcessingService = scope.ServiceProvider.GetRequiredService();\r\n // ....\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{title:"\u7279\u522b\u6ce8\u610f",type:"important",children:(0,s.jsxs)(n.p,{children:["\u5982\u679c\u662f\u975e\u5355\u4f8b\u5bf9\u8c61\uff0c\u5e94\u907f\u514d\u5728\u6784\u9020\u51fd\u6570\u4e2d\u89e3\u6790\u670d\u52a1\uff0c\u5982\u628a ",(0,s.jsx)(n.code,{children:"scope.ServiceProvider.GetRequiredService()"})," \u653e\u5728\u6784\u9020\u51fd\u6570\u4e2d\u521d\u59cb\u5316\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u670d\u52a1\u65e0\u6cd5\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"229-\u8ba2\u9605\u6267\u884c\u4efb\u52a1\u610f\u5916\u5f02\u5e38",children:"22.9 \u8ba2\u9605\u6267\u884c\u4efb\u52a1\u610f\u5916\u5f02\u5e38"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4f7f\u7528\u7684\u662f ",(0,s.jsx)(n.code,{children:"Task"})," \u5bf9\u8c61\u8fdb\u884c\u521b\u5efa\u5e76\u6267\u884c\uff0c\u4f46\u53ef\u80fd\u5b58\u5728\u4e00\u4e9b\u610f\u5916\u4e14\u96be\u4ee5\u6355\u83b7\u7684\u5f02\u5e38\uff0c\u8fd9\u65f6\u5019\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8ba2\u9605\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4}",children:"services.AddEventBus(builder =>\r\n{\r\n // \u8ba2\u9605 EventBus \u610f\u5916\u672a\u6355\u83b7\u5f02\u5e38\r\n builder.UnobservedTaskExceptionHandler = (obj, args) =>\r\n {\r\n // ....\r\n };\r\n});\n"})}),"\n",(0,s.jsx)(n.h2,{id:"2210-\u4e8b\u4ef6\u603b\u7ebf\u5de5\u5382",children:"22.10 \u4e8b\u4ef6\u603b\u7ebf\u5de5\u5382"}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 4.2.10 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u8be5\u7248\u672c\u4e2d\uff0c",(0,s.jsx)(n.code,{children:"Furion"})," \u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"IEventBusFactory"})," \u5de5\u5382\u670d\u52a1\uff0c\u53ef\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u65b0\u589e\u6216\u5220\u9664\u8ba2\u9605\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4,14-17,24}",children:'public class TestEventBus : IDynamicApiController\r\n{\r\n private readonly IEventPublisher _eventPublisher;\r\n private readonly IEventBusFactory _eventBusFactory;\r\n public TestEventBus(IEventPublisher eventPublisher, IEventBusFactory eventBusFactory)\r\n {\r\n _eventPublisher = eventPublisher;\r\n _eventBusFactory = eventBusFactory;\r\n }\r\n\r\n // \u8fd0\u884c\u65f6\u52a8\u6001\u6dfb\u52a0\u4e00\u4e2a\u8ba2\u9605\u5668\r\n public async Task AddSubscriber()\r\n {\r\n await _eventBusFactory.Subscribe("xxx", async (ctx) =>\r\n {\r\n Console.WriteLine("\u6211\u662f\u52a8\u6001\u7684");\r\n await Task.CompletedTask;\r\n });\r\n }\r\n\r\n // \u8fd0\u884c\u65f6\u52a8\u6001\u5220\u9664\u4e00\u4e2a\u8ba2\u9605\u5668\r\n public async Task RemoveDynamic(string eventId)\r\n {\r\n await _eventBusFactory.Unsubscribe(eventId);\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.h2,{id:"2211-messagecenter-\u9759\u6001\u7c7b",children:["22.11 ",(0,s.jsx)(n.code,{children:"MessageCenter"})," \u9759\u6001\u7c7b"]}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 4.3.3 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Furion 4.3.3"})," \u7248\u672c\u65b0\u589e\u4e86 ",(0,s.jsx)(n.code,{children:"MessageCenter"})," \u9759\u6001\u7c7b\uff0c\u53ef\u5728\u4efb\u4f55\u5730\u65b9\u53d1\u9001\u4e8b\u4ef6\u6d88\u606f\u6216\u8ba2\u9605\u6d88\u606f\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,5,11}",children:'// \u53d1\u9001\u6d88\u606f\uff08\u542b\u8bf8\u591a\u91cd\u8f7d\uff09\r\nawait MessageCenter.PublishAsync("messageId", new {});\r\n\r\n// \u52a8\u6001\u8ba2\u9605\u6d88\u606f\r\nMessageCenter.Subscribe("messageId", async (ctx) => {\r\n Console.WriteLine("\u6211\u662f\u52a8\u6001\u7684");\r\n await Task.CompletedTask;\r\n});\r\n\r\n// \u53d6\u6d88\u8ba2\u9605\r\nMessageCenter.Unsubscribe("messageId");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"2212-\u914d\u7f6e\u91cd\u8bd5\u5931\u8d25\u56de\u8c03",children:"22.12 \u914d\u7f6e\u91cd\u8bd5\u5931\u8d25\u56de\u8c03"}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 4.6.1 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u521b\u5efa ",(0,s.jsx)(n.code,{children:"IEventFallbackPolicy"})," \u5b9e\u73b0\u7c7b\u5e76\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"Callback"})," \u65b9\u6cd5\uff0c\u5982 ",(0,s.jsx)(n.code,{children:"EventFallbackPolicy"}),"\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,9}",children:'public class EventFallbackPolicy : IEventFallbackPolicy\r\n{\r\n private readonly ILogger _logger;\r\n public EventFallbackPolicy(ILogger logger)\r\n {\r\n _logger = logger;\r\n }\r\n\r\n public async Task CallbackAsync(EventHandlerExecutingContext context, Exception ex)\r\n {\r\n _logger.LogError(ex, "\u91cd\u8bd5\u4e86\u591a\u6b21\u6700\u7ec8\u8fd8\u662f\u5931\u8d25\u4e86");\r\n await Task.CompletedTask;\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.ol,{start:"2",children:["\n",(0,s.jsxs)(n.li,{children:["\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"EventFallbackPolicy"})," \u7c7b\u578b\u670d\u52a1"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3}",children:"services.AddEventBus(options =>\r\n{\r\n options.AddFallbackPolicy();\r\n});\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"3",children:["\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"[EventSubscribe]"})," \u7279\u6027\u914d\u7f6e ",(0,s.jsx)(n.code,{children:"FallbackPolicy"})," \u5c5e\u6027\u4f7f\u7528"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1}",children:'[EventSubscribe("test:error", NumRetries = 3, FallbackPolicy = typeof(EventFallbackPolicy))] // \u91cd\u8bd5\u4e09\u6b21\r\npublic async Task TestError(EventHandlerExecutingContext context)\r\n{\r\n Console.WriteLine("\u6211\u6267\u884c\u5566~~");\r\n throw new NotImplementedException();\r\n}\n'})}),"\n",(0,s.jsx)("img",{src:(0,i.Z)("img/nrs.png")}),"\n",(0,s.jsxs)(n.admonition,{title:"\u5c0f\u77e5\u8bc6",type:"note",children:[(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a ",(0,s.jsx)(n.code,{children:"IEventFallbackPolicy"})," \u5b9e\u73b0\u7c7b\uff0c\u7136\u540e\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"options.AddFallbackPolicy()"})," \u6ce8\u518c\u591a\u4e2a\uff0c\u8fd9\u6837\u5b9e\u73b0\u4e0d\u540c\u7684\u4e8b\u4ef6\u8ba2\u9605\u7a0b\u5e8f\u6267\u884c\u4e0d\u540c\u7684\u7b56\u7565\u3002\u5982\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3}",children:'[EventSubscribe("test:error", NumRetries = 3, FallbackPolicy = typeof(EventFallbackPolicy))]\r\n\r\n[EventSubscribe("test:error", NumRetries = 1010, FallbackPolicy = typeof(OtherEventFallbackPolicy))]\n'})})]}),"\n",(0,s.jsx)(n.h2,{id:"2213-\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u4e0d\u53ef\u7528\u65f6\u56de\u9000",children:"22.13 \u81ea\u5b9a\u4e49\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u4e0d\u53ef\u7528\u65f6\u56de\u9000"}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u81ea\u5b9a\u4e49\u4e86\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\u5982\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"Redis"}),"\u3001",(0,s.jsx)(n.code,{children:"RabbitMQ"})," \u7b49\u7b2c\u4e09\u65b9\u5b58\u50a8\u4ecb\u8d28\uff0c\u4f46\u7531\u4e8e\u4e00\u4e9b\u539f\u56e0\u5bfc\u81f4\u542f\u52a8\u65f6\u4e0d\u53ef\u7528\u5982 ",(0,s.jsx)(n.code,{children:"Redis"})," \u670d\u52a1\u672a\u542f\u52a8\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u914d\u7f6e\u9009\u62e9\u56de\u9000\u5230\u9ed8\u8ba4\u4e8b\u4ef6\u6e90\u5b58\u50a8\u5668\uff08\u5185\u5b58\uff09\u4e2d\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3,9-12}",children:"services.AddEventBus(options =>\r\n{\r\n options.ReplaceStorerOrFallback(() => new RedisEventSourceStorer(......));\r\n});\r\n\r\n// \u8fd8\u53ef\u4ee5\u89e3\u6790\u670d\u52a1\u4f20\u5165\r\nservices.AddEventBus(options =>\r\n{\r\n options.ReplaceStorerOrFallback(serviceProvider => // \u63d0\u4f9b IServiceProvider \u53ef\u89e3\u6790\u670d\u52a1\r\n {\r\n // var someService = serviceProvider.GetRequiredService();\r\n return new RedisEventSourceStorer(......);\r\n });\r\n});\n"})}),"\n",(0,s.jsx)(n.admonition,{title:"\u7279\u522b\u8bf4\u660e",type:"tip",children:(0,s.jsx)(n.p,{children:"\u76ee\u524d\u53ea\u652f\u6301\u5728\u5e94\u7528\u542f\u52a8\u65f6\u68c0\u67e5\uff0c\u4e0d\u652f\u6301\u5728\u8fd0\u884c\u65f6\u5b9e\u73b0\u6545\u969c\u8f6c\u79fb\u5207\u6362\u3002"})}),"\n",(0,s.jsxs)(n.h2,{id:"2214-eventbusoptionsbuilder-\u914d\u7f6e",children:["22.14 ",(0,s.jsx)(n.code,{children:"EventBusOptionsBuilder"})," \u914d\u7f6e"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"EventBusOptionsBuilder"})," \u662f ",(0,s.jsx)(n.code,{children:"AddEventBus"})," \u6784\u5efa\u670d\u52a1\u9009\u9879\uff0c\u8be5\u9009\u9879\u5305\u542b\u4ee5\u4e0b\u5c5e\u6027\u548c\u65b9\u6cd5\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5c5e\u6027","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"ChannelCapacity"}),"\uff1a\u9ed8\u8ba4\u5185\u5b58\u901a\u9053\u5bb9\u91cf"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"UnobservedTaskExceptionHandler"}),"\uff1a\u8ba2\u9605\u6267\u884c\u4efb\u52a1\u672a\u5bdf\u89c9\u5f02\u5e38"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"UseUtcTimestamp"}),"\uff1a\u662f\u5426\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"UTC"})," \u65f6\u95f4\uff0c",(0,s.jsx)(n.code,{children:"bool"})," \u7c7b\u578b\uff0c\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"false"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"FuzzyMatch"}),"\uff1a\u662f\u5426\u5f00\u542f\u5168\u5c40\u6a21\u7cca\u5339\u914d\uff08\u6b63\u5219\u8868\u8fbe\u5f0f\uff09\u4e8b\u4ef6 ",(0,s.jsx)(n.code,{children:"Id"}),"\uff0c",(0,s.jsx)(n.code,{children:"bool"})," \u7c7b\u578b\uff0c\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"false"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"LogEnabled"}),"\uff1a\u662f\u5426\u542f\u7528\u65e5\u5fd7\u8f93\u51fa\uff0c",(0,s.jsx)(n.code,{children:"bool"})," \u7c7b\u578b\uff0c\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"true"})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u65b9\u6cd5","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"AddSubscriber"}),"\uff1a\u6dfb\u52a0\u8ba2\u9605\u8005"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"ReplacePublisher"}),"\uff1a\u66ff\u6362\u53d1\u5e03\u8005"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"ReplaceStorer(Func)"}),"\uff1a\u66ff\u6362\u5b58\u50a8\u5668"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"ReplaceStorerOrFallback(Func)"}),"\uff1a\u66ff\u6362\u5b58\u50a8\u5668\u5982\u679c\u5931\u8d25\u5219\u56de\u6eda\u9ed8\u8ba4"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"AddMonitor"}),"\uff1a\u6dfb\u52a0\u76d1\u89c6\u5668"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"AddExecutor"}),"\uff1a\u6dfb\u52a0\u6267\u884c\u5668"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"2215-\u5173\u4e8e\u9ad8\u9891\u6d88\u606f\u5904\u7406\u65b9\u5f0f",children:"22.15 \u5173\u4e8e\u9ad8\u9891\u6d88\u606f\u5904\u7406\u65b9\u5f0f"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u4e00\u4e9b\u9ad8\u9891\u53d1\u9001\u6d88\u606f\u7684\u573a\u666f\u5982 ",(0,s.jsx)(n.code,{children:"IoT"}),"\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u6570\u636e\u91c7\u96c6\uff0c\u4e3a\u907f\u514d\u9891\u7e41\u89e3\u6790\u670d\u52a1\u548c\u521b\u5efa\u4f5c\u7528\u57df\uff0c\u53ef\u4f7f\u7528 ",(0,s.jsx)(n.strong,{children:"\u7c7b\u5168\u5c40\u4f5c\u7528\u57df"})," \u548c\u6240\u6709\u670d\u52a1\u90fd\u91c7\u53d6\u5355\u4f8b\u7684\u65b9\u5f0f\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,4,6,9,17,24-26}",children:'public class ToDoEventSubscriber : IEventSubscriber, IDisposable\r\n{\r\n private readonly ILogger _logger;\r\n private readonly IServiceScope _serviceScope;\r\n\r\n public ToDoEventSubscriber(IServiceScopeFactory scopeFactory\r\n , ILogger logger)\r\n {\r\n _serviceScope = scopeFactory.CreateScope();\r\n _logger = logger;\r\n }\r\n\r\n [EventSubscribe("iot:log")]\r\n public async Task LogFromIoT(EventHandlerExecutingContext context)\r\n {\r\n // \u89e3\u6790\u670d\u52a1\r\n var scopedProcessingService = _serviceScope.ServiceProvider.GetRequiredService();\r\n // ....\r\n }\r\n\r\n /// \r\n /// \u91ca\u653e\u670d\u52a1\u4f5c\u7528\u57df\r\n /// \r\n public void Dispose()\r\n {\r\n _serviceScope.Dispose();\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"2216-iis-\u90e8\u7f72\u56de\u6536\u8bbe\u7f6e",children:"22.16 IIS \u90e8\u7f72\u56de\u6536\u8bbe\u7f6e"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86\u4e8b\u4ef6\u603b\u7ebf\u4e14\u90e8\u7f72\u5230 ",(0,s.jsx)(n.code,{children:"IIS"})," \u4e2d\uff0c\u90a3\u4e48\u9700\u8981\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"IIS"})," \u7981\u6b62\u56de\u6536\uff0c\u907f\u514d\u4e8b\u4ef6\u603b\u7ebf\u670d\u52a1\u8fdb\u5165\u4f11\u7720\uff0c",(0,s.jsxs)(n.a,{href:"./deploy-iis#3415-iis-%E5%9B%9E%E6%94%B6%E9%97%AE%E9%A2%98%E5%92%8C%E9%85%8D%E7%BD%AE",children:["\u70b9\u51fb\u67e5\u770b ",(0,s.jsx)(n.code,{children:"IIS"})," \u56de\u6536\u95ee\u9898\u89e3\u51b3\u65b9\u6848"]})]}),"\n",(0,s.jsxs)(n.h2,{id:"2217-\u4f7f\u7528\u7b2c\u4e09\u65b9\u4e8b\u4ef6\u603b\u7ebf-cap-\u793a\u4f8b",children:["22.17 \u4f7f\u7528\u7b2c\u4e09\u65b9\u4e8b\u4ef6\u603b\u7ebf ",(0,s.jsx)(n.code,{children:"CAP"})," \u793a\u4f8b"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,5}",children:"builder.Services.AddCap(options =>\r\n{\r\n options.UseInMemoryStorage();\r\n options.UseInMemoryMessageQueue();\r\n}).AddSubscriberAssembly(App.Assemblies.ToArray());\n"})}),"\n",(0,s.jsxs)(n.h2,{id:"2218-\u5728-winformwpf-\u4e2d\u4f7f\u7528",children:["22.18 \u5728 ",(0,s.jsx)(n.code,{children:"WinForm/WPF"})," \u4e2d\u4f7f\u7528"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e8b\u4ef6\u603b\u7ebf\u652f\u6301\u5728 ",(0,s.jsx)(n.code,{children:"WinForm/WPF"})," \u4e2d\u5b8c\u6574\u7684\u4f7f\u7528\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u53d1\u9001\u4e8b\u4ef6"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3}",children:'private async void button1_Click(object sender, EventArgs e)\r\n{\r\n await _eventPublisher.PublishAsync("update.textbox", textBox1); // \u53ef\u5c06 TextBox \u63a7\u4ef6\u4f5c\u4e3a Payload \u4f20\u9012\r\n}\n'})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u8ba2\u9605\u4e8b\u4ef6\u5e76\u66f4\u65b0 ",(0,s.jsx)(n.code,{children:"UI"})]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {7,10,16}",children:'public class UIEventSubscriber : IEventSubscriber\r\n{\r\n [EventSubscribe("update.textbox")]\r\n public async Task UpdateTextBox(EventHandlerExecutingContext context)\r\n {\r\n // \u5c06 Palload \u8f6c TextBox\r\n var textbox = context.Source.Payload as TextBox;\r\n\r\n // \u591a\u7ebf\u7a0b\u66f4\u65b0 UI \u7ec4\u4ef6\uff08WinForm)\r\n textbox?.BeginInvoke(() =>\r\n {\r\n text.Text = "\u6211\u662f\u4e8b\u4ef6\u603b\u7ebf\u66f4\u65b0\u7684";\r\n });\r\n\r\n // \u591a\u7ebf\u7a0b\u66f4\u65b0 UI \u7ec4\u4ef6\uff08WPF\uff09\r\n textbox?.Dispatcher?.BeginInvoke(() =>\r\n {\r\n text.Content = " \u6211\u662f\u4e8b\u4ef6\u603b\u7ebf\u66f4\u65b0\u7684";\r\n });\r\n\r\n await Task.CompletedTask;\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"2219-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"22.19 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,s.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,s.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})})]})}function x(e={}){const{wrapper:n}={...(0,c.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},510:(e,n,r)=>{r.d(n,{Z:()=>U});r(7294);const s=(e,n,r)=>e?"string"==typeof e?e:e[n]||r:r;var c=r(5893);const i={display:"block"},o=e=>{let{size:n,color:r,style:o,...t}=e;const l=o?{...i,...o}:i;return(0,c.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:l,...t,children:(0,c.jsx)("path",{d:"M856.4 292.8c-63.3-63.6-126.6-127.1-190.2-190.3-15.3-15.2-32.7-16.1-48.1-0.8-64.3 63.6-128.1 127.6-191.8 191.9-14 14.2-16.3 31.6-1.7 46 14.8 14.7 31.5 10.6 46.1-2.7 5.1-4.6 9.8-9.7 14.7-14.7 39.2-39.7 78.5-79.5 122.8-124.4 0 170 3 332.2-1.1 494-2.4 96.4-91.2 174.6-187.4 176.6-110.6 2.3-198.6-84.4-199-197.4-0.6-136.3-0.2-272.6-0.1-408.9 0-21.8-7.9-37.4-31.2-39.9-18.9-2-33.2 13.2-33.1 37.5 0 145.8-3.4 291.7 2.4 437.2 6 152.1 160.4 263.5 309.5 230.5C591.8 900 672.8 797.2 673.6 664.6c0.8-144 0.2-288.1 0.2-432.1v-33.3c11.2 10.2 17.6 15.4 23.3 21.3 38.5 38.4 76.7 77 115.3 115.2 14.8 14.6 32.2 19.2 47.8 2.9 13.8-14.8 10.3-31.7-3.8-45.8z",fill:s(r,0,"#333333")})})};o.defaultProps={size:18};const t=o,l={display:"block"},a=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...l,...i}:l;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M143.872 768a51.2 51.2 0 0 1-15.36-2.56 51.2 51.2 0 0 1-35.328-51.2V283.136a148.992 148.992 0 0 1 141.824-153.6h450.56a148.992 148.992 0 0 1 141.824 153.6V512a148.992 148.992 0 0 1-141.824 153.6H244.224l-60.928 80.896a51.2 51.2 0 0 1-39.424 21.504zM235.008 180.224a97.792 97.792 0 0 0-90.624 102.4v430.592L218.624 614.4h466.944a97.792 97.792 0 0 0 90.624-102.4V283.136a97.792 97.792 0 0 0-90.624-102.4z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M880.128 875.52a51.2 51.2 0 0 1-39.424-20.48l-60.928-80.896h-243.2a25.6 25.6 0 0 1 0-51.2h268.8l76.288 102.4v-295.936a25.6 25.6 0 0 1 25.6-25.6 25.6 25.6 0 0 1 25.6 25.6v293.888a51.2 51.2 0 0 1-51.2 51.2z",fill:s(r,1,"#333333")})]})};a.defaultProps={size:18};const d=a,u={display:"block"},h=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...u,...i}:u;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M223.425605 449.2744l161.632237 0 0 253.65714c0 16.954137 13.745049 30.699186 30.699186 30.699186 16.95516 0 30.699186-13.745049 30.699186-30.699186l0-284.356326c0-16.95516-13.744026-30.699186-30.699186-30.699186L291.035446 387.876028l217.23665-248.51605L733.039255 387.580293 607.104031 387.580293c-16.954137 0-30.699186 13.745049-30.699186 30.699186l0 284.652062c0 16.954137 13.745049 30.699186 30.699186 30.699186s30.699186-13.745049 30.699186-30.699186L637.803217 448.978664l164.448376 0c12.140505 0 23.140023-7.154957 28.063149-18.251689 4.922103-11.097756 2.841721-24.053835-5.307889-33.05279L530.62315 72.570829c-5.881964-6.495948-14.273075-10.134825-23.024389-10.091846-8.763594 0.076748-17.076934 3.895727-22.844288 10.494005L200.312188 398.371056c-7.92653 9.067516-9.818623 21.931498-4.839215 32.896224S211.383338 449.2744 223.425605 449.2744z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M222.354204 829.113381l581.732178 0c16.954137 0 30.699186-13.745049 30.699186-30.699186s-13.745049-30.699186-30.699186-30.699186L222.354204 767.715009c-16.954137 0-30.699186 13.745049-30.699186 30.699186S205.400067 829.113381 222.354204 829.113381z",fill:s(r,1,"#333333")}),(0,c.jsx)("path",{d:"M804.086381 896.729361 222.354204 896.729361c-16.954137 0-30.699186 13.745049-30.699186 30.699186s13.745049 30.699186 30.699186 30.699186l581.732178 0c16.954137 0 30.699186-13.745049 30.699186-30.699186S821.041542 896.729361 804.086381 896.729361z",fill:s(r,2,"#333333")})]})};h.defaultProps={size:18};const x=h,m={display:"block"},p=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...m,...i}:m;return(0,c.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:(0,c.jsx)("path",{d:"M380.15463648 874.54223633c0 18.12744166-14.83154297 32.95898463-32.95898463 32.95898463s-32.95898463-14.83154297-32.95898462-32.95898463V228.9152832L172.71078883 370.86962865a33.04467773 33.04467773 0 0 1-46.60400416 0 33.04467773 33.04467773 0 0 1 0-46.6040034l197.55615234-198.14941406A32.76782227 32.76782227 0 0 1 347.0967749 116.52514674c0.03295924 0 0.06591772-0.03295924 0.09887695-0.03295924 1.54907201 0 2.90039088 0.69213867 4.41650366 0.88989258 2.66967773 0.39550781 5.40527318 0.59326172 7.94311548 1.61499049 12.03002904 4.94384766 20.59936549 16.71020508 20.59936549 30.45410156v725.0910642z m320.15698192 23.34155248a32.85351537 32.85351537 0 0 1-23.43383789 9.59106445c-0.03295924 0-0.06591772 0.03295924-0.09887696 0.03295924-1.54907201 0-2.90039088-0.69213867-4.41650365-0.92285182-2.70263697-0.36254857-5.40527318-0.56030248-7.94311549-1.61498972-12.03002904-4.91088842-20.59936549-16.67724584-20.59936473-30.42114309V149.45776367c0-18.12744166 14.83154297-32.95898463 32.95898387-32.95898463s32.95898463 14.83154297 32.95898463 32.95898463v645.60058619l141.52587916-141.92138697c12.81445313-12.82104467 33.81591797-12.82104467 46.63037109 0 12.78808619 12.81445313 12.78808619 33.77636719 0 46.60400416L700.3116184 897.88378881z",fill:s(r,0,"#333333")})})};p.defaultProps={size:18};const v=p,j={display:"block"},b=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...j,...i}:j;return(0,c.jsx)("svg",{viewBox:"0 0 1172 1024",width:n+"px",height:n+"px",style:t,...o,children:(0,c.jsx)("path",{d:"M870.0416 250.4704a38.4 38.4 0 0 0-8.96 53.5552c13.056 18.2784 24.4224 37.8368 33.7408 58.112a38.4512 38.4512 0 0 0 50.944 18.8928 38.4512 38.4512 0 0 0 18.8416-50.944 436.0192 436.0192 0 0 0-40.96-70.6048 38.3488 38.3488 0 0 0-53.6064-9.0112zM181.4528 566.016a35.9936 35.9936 0 0 0 25.5488-10.5984L351.7952 410.624a36.096 36.096 0 1 0-51.0976-51.0976L217.6 442.5728C250.0096 278.1184 395.264 153.6 569.1392 153.6c50.7904 0 99.8912 10.3936 145.92 30.9248a38.4 38.4 0 1 0 31.232-70.0928 431.36 431.36 0 0 0-177.152-37.632c-214.6816 0-393.1136 156.416-428.4416 361.216L62.1568 359.4752a36.1984 36.1984 0 0 0-51.0976 51.0976l144.8448 144.7936a36.0448 36.0448 0 0 0 25.5488 10.6496zM978.5344 463.104a36.1984 36.1984 0 0 0-51.0976 0l-144.8448 144.7936a36.096 36.096 0 1 0 51.0976 51.0976l88.6272-88.576C894.3104 740.2496 746.8032 870.4 569.1392 870.4a357.7856 357.7856 0 0 1-325.2736-207.7184 38.4 38.4 0 1 0-69.7344 32.3072 434.3808 434.3808 0 0 0 394.9568 252.2112c215.1936 0 393.984-157.184 428.6464-362.7008l74.496 74.496a35.9936 35.9936 0 0 0 51.0976 0 36.096 36.096 0 0 0 0-51.0976l-144.7936-144.7936z",fill:s(r,0,"#333333")})})};b.defaultProps={size:18};const g=b,y={display:"block"},S=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...y,...i}:y;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M302 332a30 30 0 1 1 0-60h420a30 30 0 0 1 0 60H302zM302 542a30 30 0 0 1 0-60h420a30 30 0 0 1 0 60H302zM302 752a30 30 0 0 1 0-60h120a30 30 0 0 1 0 60H302z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M789.47 784.1a30 30 0 0 1 39.36 45.3l-144.24 125.25a30 30 0 0 1-19.68 7.35H214.85C163.4 962 122 919.46 122 867.38V156.62C122 104.54 163.4 62 214.85 62h594.3C860.6 62 902 104.54 902 156.62v529.05a30 30 0 1 1-60 0V156.62C842 137.3 827.09 122 809.15 122H214.85C196.91 122 182 137.3 182 156.62v710.76C182 886.7 196.91 902 214.85 902h438.84l135.78-117.9z",fill:s(r,1,"#333333")}),(0,c.jsx)("path",{d:"M692 931.19a30 30 0 1 1-60 0v-174.6C632 704.57 673.4 662 724.85 662h147.78a30 30 0 0 1 0 60h-147.78c-17.94 0-32.85 15.3-32.85 34.62v174.6z",fill:s(r,2,"#333333")})]})};S.defaultProps={size:18};const E=S,C={display:"block"},T=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...C,...i}:C;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M512 883.2A371.2 371.2 0 1 0 140.8 512 371.2 371.2 0 0 0 512 883.2z m0 64a435.2 435.2 0 1 1 435.2-435.2 435.2 435.2 0 0 1-435.2 435.2z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M557.056 512l122.368 122.368a31.744 31.744 0 1 1-45.056 45.056L512 557.056l-122.368 122.368a31.744 31.744 0 1 1-45.056-45.056L466.944 512 344.576 389.632a31.744 31.744 0 1 1 45.056-45.056L512 466.944l122.368-122.368a31.744 31.744 0 1 1 45.056 45.056z",fill:s(r,1,"#333333")})]})};T.defaultProps={size:18};const f=T,k={display:"block"},I=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...k,...i}:k;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M940 512H792V412c76.8 0 139-62.2 139-139 0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 34.8-28.2 63-63 63H232c-34.8 0-63-28.2-63-63 0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 76.8 62.2 139 139 139v100H84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h148v96c0 6.5 0.2 13 0.7 19.3C164.1 728.6 116 796.7 116 876c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-44.2 23.9-82.9 59.6-103.7 6 17.2 13.6 33.6 22.7 49 24.3 41.5 59 76.2 100.5 100.5S460.5 960 512 960s99.8-13.9 141.3-38.2c41.5-24.3 76.2-59 100.5-100.5 9.1-15.5 16.7-31.9 22.7-49C812.1 793.1 836 831.8 836 876c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-79.3-48.1-147.4-116.7-176.7 0.4-6.4 0.7-12.8 0.7-19.3v-96h148c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM716 680c0 36.8-9.7 72-27.8 102.9-17.7 30.3-43 55.6-73.3 73.3-20.1 11.8-42 20-64.9 24.3V484c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v396.5c-22.9-4.3-44.8-12.5-64.9-24.3-30.3-17.7-55.6-43-73.3-73.3C317.7 752 308 716.8 308 680V412h408v268z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M304 280h56c4.4 0 8-3.6 8-8 0-28.3 5.9-53.2 17.1-73.5 10.6-19.4 26-34.8 45.4-45.4C450.9 142 475.7 136 504 136h16c28.3 0 53.2 5.9 73.5 17.1 19.4 10.6 34.8 26 45.4 45.4C650 218.9 656 243.7 656 272c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-40-8.8-76.7-25.9-108.1-17.2-31.5-42.5-56.8-74-74C596.7 72.8 560 64 520 64h-16c-40 0-76.7 8.8-108.1 25.9-31.5 17.2-56.8 42.5-74 74C304.8 195.3 296 232 296 272c0 4.4 3.6 8 8 8z",fill:s(r,1,"#333333")})]})};I.defaultProps={size:18};const w=I,P={display:"block"},F=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...P,...i}:P;return(0,c.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:[(0,c.jsx)("path",{d:"M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z",fill:s(r,0,"#333333")}),(0,c.jsx)("path",{d:"M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z",fill:s(r,1,"#333333")})]})};F.defaultProps={size:18};const N=F,M={display:"block"},_=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...M,...i}:M;return(0,c.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:(0,c.jsx)("path",{d:"M384 896h-64v-70.4c0-15.2-10.4-28-24.8-31.2C159.2 768 64 644.8 64 496v-32h64v32c0 118.4 73.6 215.2 179.2 236 44.8 8.8 76.8 48 76.8 94.4v69.6zM704 896h-64v-70.4c0-45.6 32-85.6 76.8-94.4C822.4 711.2 896 614.4 896 496v-32h64v32c0 148.8-95.2 272-231.2 298.4-14.4 3.2-24.8 16-24.8 31.2v70.4zM512.8 640l-41.6-37.6c-147.2-133.6-244-208-244-316.8 0-88 68.8-156.8 156.8-156.8 49.6 0 97.6 23.2 128.8 60C544 152 592 128.8 641.6 128.8c88 0 156.8 68.8 156.8 156.8 0 108-96.8 183.2-244 316.8L512.8 640z",fill:s(r,0,"#333333")})})};_.defaultProps={size:18};const B=_,D={display:"block"},A=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...D,...i}:D;return(0,c.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:(0,c.jsx)("path",{d:"M942.4615936 284.62787926c-14.30911886-14.12709945-37.31996786-14.05468217-51.48229632 0.21920654L517.97142983 661.27810333 139.75544149 286.45003606c-14.30911886-14.16232846-37.31996786-14.05468217-51.51948344 0.21920654-14.16232846 14.30911886-14.05468217 37.35519687 0.21920654 51.51948345l401.99014627 398.34974663c0.61847666 0.61847666 1.41897273 0.76526706 2.03940637 1.34655658 0.14483342 0.14483342 0.18201941 0.32685283 0.32685283 0.47364324 7.09877874 7.02636259 16.38375538 10.55911595 25.63154489 10.55911595 9.35739278 0 18.75001458-3.60516949 25.85075143-10.77636551l398.34974663-401.99014628C956.84312974 321.8382427 956.73548345 298.7921647 942.4615936 284.62787926z",fill:s(r,0,"#333333")})})};A.defaultProps={size:18};const L=A,R={display:"block"},z=e=>{let{size:n,color:r,style:i,...o}=e;const t=i?{...R,...i}:R;return(0,c.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:t,...o,children:(0,c.jsx)("path",{d:"M81.5384064 739.37212074c14.30911886 14.12709945 37.31996786 14.05468217 51.48229632-0.21920654L506.02857017 362.72189667 884.24455851 737.54996394c14.30911886 14.16232846 37.31996786 14.05468217 51.51948344-0.21920654 14.16232846-14.30911886 14.05468217-37.35519687-0.21920654-51.51948345l-401.99014627-398.34974663c-0.61847666-0.61847666-1.41897273-0.76526706-2.03940637-1.34655658-0.14483342-0.14483342-0.18201941-0.32685283-0.32685282-0.47364324-7.09877874-7.02636259-16.38375538-10.55911595-25.6315449-10.55911595-9.35739278 0-18.75001458 3.60516949-25.85075143 10.77636551l-398.34974663 401.99014628C67.15687026 702.1617573 67.26451655 725.2078353 81.5384064 739.37212074z",fill:s(r,0,"#333333")})})};z.defaultProps={size:18};const H=z,O=e=>{let{name:n,...r}=e;switch(n){case"youhua":return(0,c.jsx)(t,{...r});case"dayi":return(0,c.jsx)(d,{...r});case"shengji":return(0,c.jsx)(x,{...r});case"tiaozheng":return(0,c.jsx)(v,{...r});case"gengxin":return(0,c.jsx)(g,{...r});case"wendang":return(0,c.jsx)(E,{...r});case"shanchu":return(0,c.jsx)(f,{...r});case"bug":return(0,c.jsx)(w,{...r});case"xinzeng":return(0,c.jsx)(N,{...r});case"fuwu":return(0,c.jsx)(B,{...r});case"down":return(0,c.jsx)(L,{...r});case"up":return(0,c.jsx)(H,{...r})}return null},K={label:"label_p8vM",icon:"icon_knQK"};function U(e){const{children:n}=e,r={"\u65b0\u589e":{icon:"xinzeng",bgColor:"#39b54a"},"\u4fee\u590d":{icon:"bug",bgColor:"#9c26b0"},"\u6587\u6863":{icon:"wendang",bgColor:"rgb(79, 147, 255)"},"\u66f4\u65b0":{icon:"gengxin",bgColor:"#0081ff"},"\u8c03\u6574":{icon:"tiaozheng",bgColor:"#333"},"\u5347\u7ea7":{icon:"shengji",bgColor:"#e03997"},"\u79fb\u9664":{icon:"shanchu",bgColor:"#666"},"\u7b54\u7591":{icon:"dayi",bgColor:"#bbb"},"\u4f18\u5316":{icon:"youhua",bgColor:"#38e550"}};return(0,c.jsxs)("label",{className:K.label,title:n,style:{backgroundColor:r[n].bgColor},children:[(0,c.jsx)(O,{name:r[n].icon,color:"white",size:14,className:K.icon})," ",n]})}},1151:(e,n,r)=>{r.d(n,{Z:()=>t,a:()=>o});var s=r(7294);const c={},i=s.createContext(c);function o(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:o(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]);