forked from abpframework/abp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
371 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/DbContextEventOutbox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Threading.Tasks; | ||
using Volo.Abp.EventBus.Distributed; | ||
using Volo.Abp.Guids; | ||
|
||
namespace Volo.Abp.EntityFrameworkCore.DistributedEvents | ||
{ | ||
public class DbContextEventOutbox<TDbContext> : IEventOutbox | ||
where TDbContext : IHasEventOutbox | ||
{ | ||
protected IDbContextProvider<TDbContext> DbContextProvider { get; } | ||
protected IGuidGenerator GuidGenerator { get; } | ||
|
||
public DbContextEventOutbox( | ||
IDbContextProvider<TDbContext> dbContextProvider, | ||
IGuidGenerator guidGenerator) | ||
{ | ||
DbContextProvider = dbContextProvider; | ||
GuidGenerator = guidGenerator; | ||
} | ||
|
||
public async Task EnqueueAsync(string eventName, byte[] eventData) | ||
{ | ||
var dbContext = (IHasEventOutbox) await DbContextProvider.GetDbContextAsync(); | ||
dbContext.OutgoingEventRecords.Add( | ||
new OutgoingEventRecord(GuidGenerator.Create(), eventName, eventData) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/IRabbitMqSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace Volo.Abp.EventBus.Rebus | ||
{ | ||
public interface IRebusSerializer | ||
{ | ||
byte[] Serialize(object obj); | ||
|
||
object Deserialize(byte[] value, Type type); | ||
|
||
T Deserialize<T>(byte[] value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/Utf8JsonRabbitMqSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Text; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.Json; | ||
|
||
namespace Volo.Abp.EventBus.Rebus | ||
{ | ||
public class Utf8JsonRebusSerializer : IRebusSerializer, ITransientDependency | ||
{ | ||
private readonly IJsonSerializer _jsonSerializer; | ||
|
||
public Utf8JsonRebusSerializer(IJsonSerializer jsonSerializer) | ||
{ | ||
_jsonSerializer = jsonSerializer; | ||
} | ||
|
||
public byte[] Serialize(object obj) | ||
{ | ||
return Encoding.UTF8.GetBytes(_jsonSerializer.Serialize(obj)); | ||
} | ||
|
||
public object Deserialize(byte[] value, Type type) | ||
{ | ||
return _jsonSerializer.Deserialize(type, Encoding.UTF8.GetString(value)); | ||
} | ||
|
||
public T Deserialize<T>(byte[] value) | ||
{ | ||
return _jsonSerializer.Deserialize<T>(Encoding.UTF8.GetString(value)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IEventOutbox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Volo.Abp.EventBus.Distributed | ||
{ | ||
public interface IEventOutbox | ||
{ | ||
Task EnqueueAsync(string eventName, byte[] eventData); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace Volo.Abp.EventBus.Distributed | ||
{ | ||
public class OutboxConfig | ||
{ | ||
public string Name { get; } | ||
|
||
public Type ImplementationType { get; set; } | ||
public Func<Type, bool> Selector { get; set; } | ||
|
||
public OutboxConfig(string name, Type implementationType, Func<Type, bool> selector = null) | ||
{ | ||
Name = name; | ||
ImplementationType = implementationType; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxConfigList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Volo.Abp.EventBus.Distributed | ||
{ | ||
public class OutboxConfigList : List<OutboxConfig> | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.