fix:序列化器改为newtonsoft,取消队列独占模式
This commit is contained in:
parent
259113ad1e
commit
57d21822a8
@ -11,6 +11,7 @@
|
|||||||
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
|
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
|
||||||
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/>
|
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/>
|
||||||
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview12" />
|
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview12" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.18" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
|
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
|||||||
@ -25,6 +25,8 @@ public class InterfaceForwardApiModule : FakeModule
|
|||||||
{
|
{
|
||||||
options.ScanApplicationServices<InterfaceForwardApplicationModule>();
|
options.ScanApplicationServices<InterfaceForwardApplicationModule>();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddMvc().AddNewtonsoftJson();
|
||||||
|
|
||||||
services.AddFakeSwaggerGen()
|
services.AddFakeSwaggerGen()
|
||||||
.AddFakeExceptionFilter()
|
.AddFakeExceptionFilter()
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"FeiShuNotice": {
|
"FeiShuNotice": {
|
||||||
"Title": "InterfaceForward-Dev",
|
"Title": "InterfaceForward-Dev",
|
||||||
"Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/255c44ff-5891-4902-9b6a-6d0250e745f7",
|
"Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/e5ced977-a616-42ce-8684-c7628e71b35e",
|
||||||
"Timeout": 20
|
"Timeout": 20
|
||||||
},
|
},
|
||||||
"Redis": {
|
"Redis": {
|
||||||
|
|||||||
@ -19,8 +19,9 @@ public class RabbitClient(
|
|||||||
if (!channelAccessor.IsNew) return;
|
if (!channelAccessor.IsNew) return;
|
||||||
|
|
||||||
var channel = channelAccessor.Channel;
|
var channel = channelAccessor.Channel;
|
||||||
|
var decl = new DefaultDeclaration(channel);
|
||||||
|
|
||||||
consumeOptions.Declaration.Invoke(channel);
|
consumeOptions.Declaration.Invoke(decl);
|
||||||
|
|
||||||
if (consumeOptions.FetchCount > 0)
|
if (consumeOptions.FetchCount > 0)
|
||||||
{
|
{
|
||||||
@ -82,5 +83,60 @@ public class ConsumeOptions
|
|||||||
|
|
||||||
public bool FailedRequeue { get; set; }
|
public bool FailedRequeue { get; set; }
|
||||||
|
|
||||||
public Action<IModel> Declaration { get; set; }
|
public Action<IDeclaration> Declaration { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface IDeclaration
|
||||||
|
{
|
||||||
|
void QueueDeclare(string queue, bool durable, bool autoDelete = false, bool exclusive = false,
|
||||||
|
IDictionary<string, object> arguments = null);
|
||||||
|
|
||||||
|
void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete = false,
|
||||||
|
IDictionary<string, object> arguments = null);
|
||||||
|
|
||||||
|
void QueueBind(string queue, string exchange, string routingKey,
|
||||||
|
IDictionary<string, object> arguments = null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DefaultDeclaration : IDeclaration
|
||||||
|
{
|
||||||
|
private readonly IModel _chnl;
|
||||||
|
|
||||||
|
// ReSharper disable once ConvertToPrimaryConstructor
|
||||||
|
public DefaultDeclaration(IModel chnl)
|
||||||
|
{
|
||||||
|
_chnl = chnl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void QueueDeclare(string queue, bool durable, bool autoDelete = false, bool exclusive = false,
|
||||||
|
IDictionary<string, object> arguments = null)
|
||||||
|
{
|
||||||
|
_chnl.QueueDeclare(
|
||||||
|
queue: queue,
|
||||||
|
durable: durable,
|
||||||
|
autoDelete: autoDelete,
|
||||||
|
exclusive: exclusive,
|
||||||
|
arguments: arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete = false,
|
||||||
|
IDictionary<string, object> arguments = null)
|
||||||
|
{
|
||||||
|
_chnl.ExchangeDeclare(
|
||||||
|
exchange: exchange,
|
||||||
|
type: type,
|
||||||
|
durable: durable,
|
||||||
|
autoDelete: autoDelete,
|
||||||
|
arguments: arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void QueueBind(string queue, string exchange, string routingKey, IDictionary<string, object> arguments)
|
||||||
|
{
|
||||||
|
_chnl.QueueBind(
|
||||||
|
queue: queue,
|
||||||
|
exchange: exchange,
|
||||||
|
routingKey: routingKey,
|
||||||
|
arguments: arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user