Search in sources :

Example 1 with Blocking

use of io.smallrye.common.annotation.Blocking in project quarkus-quickstarts by quarkusio.

the class StarWarsResource method getAllFilmsUsingDynamicClient.

@GET
@Path("/dynamic")
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public List<Film> getAllFilmsUsingDynamicClient() throws Exception {
    Document query = document(operation(field("allFilms", field("films", field("title"), field("planetConnection", field("planets", field("name")))))));
    Response response = dynamicClient.executeSync(query);
    // translate it into an instance of the corresponding model class
    return response.getObject(FilmConnection.class, "allFilms").getFilms();
}
Also used : Response(io.smallrye.graphql.client.Response) FilmConnection(org.acme.microprofile.graphql.client.model.FilmConnection) Document(io.smallrye.graphql.client.core.Document) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Blocking(io.smallrye.common.annotation.Blocking)

Example 2 with Blocking

use of io.smallrye.common.annotation.Blocking 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)

Example 3 with Blocking

use of io.smallrye.common.annotation.Blocking in project openk9 by smclab.

the class TenantRegistry method initializeTenantMap.

@Scheduled(every = "30s")
@Blocking
void initializeTenantMap() {
    List<Tenant> listTenant = Tenant.<Tenant>list("active = true").await().indefinitely();
    Map<String, Tenant> map = new HashMap<>(listTenant.size());
    for (Tenant tenant : listTenant) {
        map.put(tenant.getVirtualHost(), tenant);
    }
    _tenantMap.clear();
    _tenantMap.putAll(map);
}
Also used : Tenant(io.openk9.api.aggregator.model.Tenant) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Scheduled(io.quarkus.scheduler.Scheduled) Blocking(io.smallrye.common.annotation.Blocking)

Aggregations

Blocking (io.smallrye.common.annotation.Blocking)3 NewBankAccount (com.redhat.training.bank.message.NewBankAccount)1 BankAccount (com.redhat.training.bank.model.BankAccount)1 Tenant (io.openk9.api.aggregator.model.Tenant)1 Scheduled (io.quarkus.scheduler.Scheduled)1 Response (io.smallrye.graphql.client.Response)1 Document (io.smallrye.graphql.client.core.Document)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Transactional (javax.transaction.Transactional)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 FilmConnection (org.acme.microprofile.graphql.client.model.FilmConnection)1 Incoming (org.eclipse.microprofile.reactive.messaging.Incoming)1