public void Handle() { _serviceBusSubscriber.To("CustomerServiceRequest", async(messageType, payload, messageId) => { if (messageType.ToLowerInvariant() == nameof(ReserveCreditCommand).ToLowerInvariant()) { await _serviceBusPublisher.Publish("CustomerServiceReply", new CustomerCreditExceededEvent("Exceeded customer credit limit")); } }); }
public override void OnSubscribe() { _serviceBusSubscriber.To(_queue, (messageType, payload, messageId) => { if (messageType.ToLowerInvariant() == nameof(CustomerCreditReservedEvent).ToLowerInvariant()) { CustomerCreditReservedEvent customerCreditReservedEvent = JsonConvert.DeserializeObject <CustomerCreditReservedEvent>(payload); Success(customerCreditReservedEvent); } else if (messageType.ToLowerInvariant() == nameof(CustomerCreditExceededEvent).ToLowerInvariant()) { CustomerCreditExceededEvent customerCreditReservedEvent = JsonConvert.DeserializeObject <CustomerCreditExceededEvent>(payload); Failure(customerCreditReservedEvent); } }); }