KafkaAutoConfiguration僅kafkaTransactionManager在設定了“spring.kafka.producer.transaction-id-prefix”屬性時才配置 bean。
是否可以設定此屬性以在僅使用來自主題的資料且沒有任何生產者邏輯的應用程式中獲取此自動配置的 bean?
我將在我的消費者應用程式中實作 1pc 盡力而為模式,因此我需要同時擁有兩者kafkaTransactionManager并JpaTransactionManager在背景關系中將它們與@Transactional注釋一起使用。
uj5u.com熱心網友回復:
如果您不使用生產者端,則不需要 this KafkaTransactionManager。只需將其JpaTransactionManager注入ContainerProperties:
/**
* Set the transaction manager to start a transaction; offsets are committed with
* semantics equivalent to {@link AckMode#RECORD} and {@link AckMode#BATCH} depending
* on the listener type (record or batch).
* @param transactionManager the transaction manager.
* @since 1.3
* @see #setAckMode(AckMode)
*/
public void setTransactionManager(@Nullable PlatformTransactionManager transactionManager) {
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/455377.html
上一篇:插入新資料時呼叫服務
