33using Blog . Core . Common . HttpContextUser ;
44using Blog . Core . Common . HttpRestSharp ;
55using Blog . Core . Common . WebApiClients . HttpApis ;
6+ using Blog . Core . EventBus ;
7+ using Blog . Core . EventBus . EventHandling ;
68using Blog . Core . Filter ;
79using Blog . Core . IServices ;
810using Blog . Core . Model ;
1315using System ;
1416using System . Collections . Generic ;
1517using System . ComponentModel . DataAnnotations ;
18+ using System . Threading ;
1619using System . Threading . Tasks ;
1720
1821namespace Blog . Core . Controllers
@@ -132,15 +135,32 @@ public async Task<MessageModel<ResponseEnum>> Get()
132135 return data ;
133136 }
134137
138+ /// <summary>
139+ /// 测试Redis消息队列
140+ /// </summary>
141+ /// <param name="_redisBasketRepository"></param>
142+ /// <returns></returns>
135143 [ HttpGet ]
136144 [ AllowAnonymous ]
137145 public async Task RedisMq ( [ FromServices ] IRedisBasketRepository _redisBasketRepository )
138146 {
139147 var msg = $ "这里是一条日志{ DateTime . Now } ";
140148 await _redisBasketRepository . ListLeftPushAsync ( RedisMqKey . Loging , msg ) ;
149+ }
150+
151+ /// <summary>
152+ /// 测试RabbitMQ事件总线
153+ /// </summary>
154+ /// <param name="_eventBus"></param>
155+ /// <param name="blogId"></param>
156+ /// <returns></returns>
157+ [ HttpGet ]
158+ [ AllowAnonymous ]
159+ public void EventBusTry ( [ FromServices ] IEventBus _eventBus , string blogId = "1" )
160+ {
161+ var blogDeletedEvent = new BlogDeletedIntegrationEvent ( blogId ) ;
141162
142- //var priceChangedEvent = new ProductPriceChangedIntegrationEvent(catalogItem.Id, productToUpdate.Price, oldPrice);
143- //_eventBus.Publish(evt);
163+ _eventBus . Publish ( blogDeletedEvent ) ;
144164 }
145165
146166 /// <summary>
@@ -167,7 +187,7 @@ public ActionResult<string> Get(int id)
167187 /// <returns></returns>
168188 [ HttpGet ]
169189 [ Route ( "/api/values/RequiredPara" ) ]
170- public string RequiredP ( [ Required ] string id )
190+ public string RequiredP ( [ Required ] string id )
171191 {
172192 return id ;
173193 }
@@ -221,7 +241,7 @@ public string Destination()
221241 /// <param name="id">独立参数</param>
222242 [ HttpPost ]
223243 [ AllowAnonymous ]
224- public object Post ( [ FromBody ] BlogArticle blogArticle , int id )
244+ public object Post ( [ FromBody ] BlogArticle blogArticle , int id )
225245 {
226246 return Ok ( new { success = true , data = blogArticle , id = id } ) ;
227247 }
0 commit comments