Search in sources :

Example 1 with NewBankAccount

use of com.redhat.training.bank.message.NewBankAccount in project AD482-apps by RedHatTraining.

the class AccountResource method sendMessageAboutNewBankAccount.

private void sendMessageAboutNewBankAccount(BankAccount bankAccount) {
    LOGGER.info("New Bank Account - ID: " + bankAccount.id + ", Balance: " + bankAccount.balance);
    // TODO: Send a message about the new bank account
    emitter.send(new NewBankAccount(bankAccount.id, bankAccount.balance));
}
Also used : NewBankAccount(com.redhat.training.bank.message.NewBankAccount)

Example 2 with NewBankAccount

use of com.redhat.training.bank.message.NewBankAccount in project AD482-apps by RedHatTraining.

the class NewBankAccountConsumer method processMessage.

// TODO: Create the consumer implementation
@Incoming("new-bank-account-in")
@Blocking
@Transactional
public void processMessage(NewBankAccount message) {
    BankAccount entity = BankAccount.findById(message.getId());
    if (entity != null) {
        entity.profile = message.getBalance() < 100000 ? "regular" : "premium";
        LOGGER.info("Updated Bank Account - ID: " + message.getId() + " - Type: " + entity.profile);
    } else {
        LOGGER.info("Bank Account not found!");
    }
}
Also used : BankAccount(com.redhat.training.bank.model.BankAccount) NewBankAccount(com.redhat.training.bank.message.NewBankAccount) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming) Blocking(io.smallrye.common.annotation.Blocking) Transactional(javax.transaction.Transactional)

Aggregations

NewBankAccount (com.redhat.training.bank.message.NewBankAccount)2 BankAccount (com.redhat.training.bank.model.BankAccount)1 Blocking (io.smallrye.common.annotation.Blocking)1 Transactional (javax.transaction.Transactional)1 Incoming (org.eclipse.microprofile.reactive.messaging.Incoming)1