-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ofmaska/master
Handle PaymentCompletedEvent #6
- Loading branch information
Showing
3 changed files
with
19 additions
and
12 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
19 changes: 12 additions & 7 deletions
19
src/MAVN.Service.SmartVouchers.DomainServices/RabbitSubscribers/RabbitSubscriber.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 |
---|---|---|
@@ -1,30 +1,35 @@ | ||
using System.Threading.Tasks; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Common.Log; | ||
using Lykke.Common.Log; | ||
using Lykke.RabbitMqBroker.Subscriber; | ||
using MAVN.Service.PaymentManagement.Contract; | ||
using MAVN.Service.SmartVouchers.Domain.Services; | ||
|
||
namespace MAVN.Service.SmartVouchers.DomainServices.RabbitSubscribers | ||
{ | ||
// TODO replace object with required message type | ||
public class RabbitSubscriber : JsonRabbitSubscriber<object> | ||
public class RabbitSubscriber : JsonRabbitSubscriber<PaymentCompletedEvent> | ||
{ | ||
private readonly ILog _log; | ||
private readonly IVouchersService _voucherService; | ||
|
||
public RabbitSubscriber( | ||
string connectionString, | ||
string exchangeName, | ||
string queueName, | ||
ILogFactory logFactory) | ||
ILogFactory logFactory, | ||
IVouchersService voucherService) | ||
: base(connectionString, exchangeName, queueName, logFactory) | ||
{ | ||
_log = logFactory.CreateLog(this); | ||
_voucherService = voucherService; | ||
} | ||
|
||
protected override async Task ProcessMessageAsync(object message) | ||
protected override async Task ProcessMessageAsync(PaymentCompletedEvent evt) | ||
{ | ||
await Task.CompletedTask; // TODO replace this with proper message handling | ||
await _voucherService.ProcessPaymentRequestAsync(Guid.Parse(evt.PaymentRequestId)); | ||
|
||
_log.Info($"Handled {typeof(object).Name}", message); | ||
_log.Info($"Handled {typeof(object).Name}", evt); | ||
} | ||
} | ||
} |
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