Browse Source

RabbitMq support finished (#3)

pull/65/head
Sebastian Stehle 10 years ago
parent
commit
348dfa301a
  1. 17
      Squidex.sln
  2. 7
      src/Squidex.Infrastructure.RabbitMq/RabbitMqEventConsumer.cs
  3. 10
      src/Squidex.Infrastructure.RabbitMq/RabbitMqOptions.cs
  4. 2
      src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj
  5. 1
      src/Squidex.Infrastructure/CQRS/Events/EventReceiver.cs
  6. 3
      src/Squidex/Config/Domain/RabbitMqModule.cs
  7. 2
      src/Squidex/Squidex.csproj
  8. 2
      src/Squidex/appsettings.json
  9. 1
      tests/Squidex.Infrastructure.Tests/Log/SemanticLogTests.cs

17
Squidex.sln

@ -32,10 +32,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Read.Tests", "tests
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Infrastructure.Redis", "src\Squidex.Infrastructure.Redis\Squidex.Infrastructure.Redis.csproj", "{D7166C56-178A-4457-B56A-C615C7450DEE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{1667F3B4-31E6-45B2-90FB-97B1ECFE9874}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "GenerateLanguages", "tools\GenerateLanguages\GenerateLanguages.csproj", "{927E1F1C-95F0-4991-B33F-603977204B02}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Infrastructure.RabbitMq", "src\Squidex.Infrastructure.RabbitMq\Squidex.Infrastructure.RabbitMq.csproj", "{C1E5BBB6-6B6A-4DE5-B19D-0538304DE343}"
EndProject
Global
@ -152,18 +148,6 @@ Global
{D7166C56-178A-4457-B56A-C615C7450DEE}.Release|Any CPU.Build.0 = Release|Any CPU
{D7166C56-178A-4457-B56A-C615C7450DEE}.Release|x64.ActiveCfg = Release|Any CPU
{D7166C56-178A-4457-B56A-C615C7450DEE}.Release|x86.ActiveCfg = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|x64.ActiveCfg = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|x64.Build.0 = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|x86.ActiveCfg = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Debug|x86.Build.0 = Debug|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|Any CPU.Build.0 = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|x64.ActiveCfg = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|x64.Build.0 = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|x86.ActiveCfg = Release|Any CPU
{927E1F1C-95F0-4991-B33F-603977204B02}.Release|x86.Build.0 = Release|Any CPU
{C1E5BBB6-6B6A-4DE5-B19D-0538304DE343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1E5BBB6-6B6A-4DE5-B19D-0538304DE343}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1E5BBB6-6B6A-4DE5-B19D-0538304DE343}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -193,7 +177,6 @@ Global
{6A811927-3C37-430A-90F4-503E37123956} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF}
{8B074219-F69A-4E41-83C6-12EE1E647779} = {4C6B06C2-6D77-4E0E-AE32-D7050236433A}
{D7166C56-178A-4457-B56A-C615C7450DEE} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF}
{927E1F1C-95F0-4991-B33F-603977204B02} = {1667F3B4-31E6-45B2-90FB-97B1ECFE9874}
{C1E5BBB6-6B6A-4DE5-B19D-0538304DE343} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF}
EndGlobalSection
EndGlobal

7
src/Squidex.Infrastructure.RabbitMq/RabbitMqEventConsumer.cs

@ -20,6 +20,7 @@ namespace Squidex.Infrastructure.RabbitMq
{
public sealed class RabbitMqEventConsumer : DisposableObjectBase, IExternalSystem, IEventConsumer
{
private readonly JsonSerializerSettings serializerSettings;
private readonly string exchange;
private readonly string streamFilter;
private readonly ConnectionFactory connectionFactory;
@ -36,10 +37,11 @@ namespace Squidex.Infrastructure.RabbitMq
get { return streamFilter; }
}
public RabbitMqEventConsumer(string uri, string exchange, string streamFilter)
public RabbitMqEventConsumer(JsonSerializerSettings serializerSettings, string uri, string exchange, string streamFilter)
{
Guard.NotNullOrEmpty(uri, nameof(uri));
Guard.NotNullOrEmpty(exchange, nameof(exchange));
Guard.NotNull(serializerSettings, nameof(serializerSettings));
connectionFactory = new ConnectionFactory { Uri = uri };
@ -49,6 +51,7 @@ namespace Squidex.Infrastructure.RabbitMq
this.exchange = exchange;
this.streamFilter = streamFilter;
this.serializerSettings = serializerSettings;
}
protected override void DisposeObject(bool disposing)
@ -84,7 +87,7 @@ namespace Squidex.Infrastructure.RabbitMq
public Task On(Envelope<IEvent> @event)
{
var jsonString = JsonConvert.SerializeObject(@event);
var jsonString = JsonConvert.SerializeObject(@event, serializerSettings);
var jsonBytes = Encoding.UTF8.GetBytes(jsonString);
channel.Value.BasicPublish(exchange, string.Empty, null, jsonBytes);

10
src/Squidex.Infrastructure.RabbitMq/RabbitMqOptions.cs

@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Squidex.Infrastructure.RabbitMq
{
class RabbitMqOptions
{
}
}

2
src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj

@ -10,6 +10,6 @@
<PackageReference Include="RabbitMQ.Client" Version="4.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup>
</Project>

1
src/Squidex.Infrastructure/CQRS/Events/EventReceiver.cs

@ -7,7 +7,6 @@
// ==========================================================================
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Timers;

3
src/Squidex/Config/Domain/RabbitMqModule.cs

@ -8,6 +8,7 @@
using Autofac;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.RabbitMq;
@ -37,7 +38,7 @@ namespace Squidex.Config.Domain
{
var streamFilter = Configuration.GetValue<string>("squidex:eventPublishers:rabbitMq:streamFilter");
builder.Register(c => new RabbitMqEventConsumer(connectionString, exchange, streamFilter))
builder.Register(c => new RabbitMqEventConsumer(c.Resolve<JsonSerializerSettings>(), connectionString, exchange, streamFilter))
.As<IEventConsumer>()
.As<IExternalSystem>()
.SingleInstance();

2
src/Squidex/Squidex.csproj

@ -23,9 +23,9 @@
<ItemGroup>
<ProjectReference Include="..\Squidex.Core\Squidex.Core.csproj" />
<ProjectReference Include="..\Squidex.Events\Squidex.Events.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.RabbitMq\Squidex.Infrastructure.RabbitMq.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.MongoDb\Squidex.Infrastructure.MongoDb.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.RabbitMq\Squidex.Infrastructure.RabbitMq.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.Redis\Squidex.Infrastructure.Redis.csproj" />
<ProjectReference Include="..\Squidex.Read\Squidex.Read.csproj" />
<ProjectReference Include="..\Squidex.Read.MongoDb\Squidex.Read.MongoDb.csproj" />

2
src/Squidex/appsettings.json

@ -22,7 +22,7 @@
"eventPublishers": {
"rabbitMq": {
"connectionString": "amqp://guest:guest@localhost/",
"exchange": "Squidex",
"exchange": "squidex",
"enabled": false,
"streamFilter": "*"
}

1
tests/Squidex.Infrastructure.Tests/Log/SemanticLogTests.cs

@ -8,7 +8,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Extensions.Logging;
using Moq;
using Squidex.Infrastructure.Log.Adapter;

Loading…
Cancel
Save