我正在使用Spring Framework開發Web應用程序。我有兩個服務將存儲一些處理結果到數據庫中的一個表T中。邏輯目前是:兩個進程駐留在不同的AP服務器中,並引用相同的布爾標誌。 (Spring,Java)
服務A
for all items:
result = func(item)
store result to Table T (with status = new)
is_running = False
服務B
for some items:
if is_running == False:
result = func(item)
store result to Table T (with status = new)
else:
store result to Table T (with status = inprogress)
布爾標誌is_running
將在服務A.
由於我們有一個字段用於域服務器,服務A和服務B的MicroService Architechture可以駐留在不同的AP服務器中。如何確保服務A和服務B參考相同的is_running
?
是否可以使用Spring's bean scope來實現?