本文介紹了阻止EntityManager操作的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我不想執(zhí)行阻止操作。
Caused by: java.lang.IllegalStateException: You have attempted to perform a blocking operation on a IO thread. This is not allowed, as blocking the IO thread will cause major performance issues with your application. If you want to perform blocking EntityManager operations make sure you are doing it from a worker thread.
有人知道如何解決此問(wèn)題嗎?
我只有簡(jiǎn)單的手術(shù)。返回10行的單個(gè)findAll請(qǐng)求。我把交易交易從沒(méi)有
我仍然有這個(gè)問(wèn)題。
我正在使用簡(jiǎn)單實(shí)體的Panache。
@GET
@Path("/type")
@Produces(MediaType.APPLICATION_JSON)
@Transactional(Transactional.TxType.NEVER)
public Response get() {
return AlertType.listAll();
}
public class AlerteType extends PanacheEntityBase
{
@Column(name="ATY_ACTIVE")
private String active;
@Column(name="ATY_ID")
@Id
private Long oraId;
@Column(name="ATY_TYPE")
private String type;
}
謝謝
推薦答案
如果您想繼續(xù)使用非反應(yīng)性代碼,可以在方法get()
上使用@Blocking
注釋。它將在工作線程(而不是一個(gè)IO線程)上分流計(jì)算。
Quarkus對(duì)IO線程非常挑剔,您不能阻止它們。如果您有類(lèi)似數(shù)據(jù)庫(kù)調(diào)用(或任何遠(yuǎn)程調(diào)用)的東西,它就是阻塞的。因此您不能在IO線程中執(zhí)行此操作。
更多信息:
https://quarkus.io/guides/getting-started-reactive
https://quarkus.io/blog/resteasy-reactive-faq/
這篇關(guān)于阻止EntityManager操作的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,