我在mule flow中遇到数据库事务的问题.这是我定义的流程:
<flow name="createPortinCaseServiceFlow">
<vm:inbound-endpoint path="createPortinCase" exchange-pattern="request-response">
<custom-transaction action="ALWAYS_BEGIN" factory-ref="muleTransactionFactory"/>
</vm:inbound-endpoint>
<component>
<spring-object bean="checkIfExists"/>
</component>
<component>
<spring-object bean="createNewOne"/>
</component>
</flow>
Run Code Online (Sandbox Code Playgroud)
我们的想法是,在checkIfExists中,我们验证是否存在某些数据(在数据库中)是否存在异常.如果不是,我们去createNewOne并创建一个新数据.
如果我们同时运行流程,则会在createNewOne中多次创建新对象,并且它们不应该像我们之前调用checkIfExists一样.这意味着交易无法正常运作.
既createNewOne和checkIfExists有以下注释:
@Transactional(propagation = Propagation.MANDATORY)
Run Code Online (Sandbox Code Playgroud)
muleTransactionFactory的定义如下所示
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="dataSource" ref="teleportNpDataSource"/>
<property name="entityManagerFactory" ref="npEntityManagerFactory"/>
<property name="nestedTransactionAllowed" value="true"/>
<property name="defaultTimeout" value="${teleport.np.tm.transactionTimeout}"/>
</bean>
<bean id="muleTransactionFactory" class="org.mule.module.spring.transaction.SpringTransactionFactory">
<property name="manager" ref="transactionManager"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我已经设置了TRACE日志级别(如@Shailendra建议的那样),我发现事务在所有spring bean中都被重用:
00:26:32.751 [pool-75-thread-1] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Participating in existing transaction
Run Code Online (Sandbox Code Playgroud)
在日志中,事务同时提交,这意味着这些事务是正确创建的,但是并发执行会导致问题.
我得到 +CME ERROR: 10 on setting AT+COPS=1 下面是我的终端 AT 命令输出:
AT
OK
AT+CSQ
+CSQ: 12,0
OK
AT+CMEE=1
OK
AT+COPS=?
+COPS: (2,"405800","405800","405800"),(1,"40505","40505","40505"),(????1,"AirTel","AirTel??",??"40410"),(1," IDEA CELLULAR Ltd","IDEA","40404"),,(0-4),(0-2)
OK
AT+COPS?
+COPS: 0
OK
AT+COPS=1
+CME
ERROR: 10
AT+COPS?
+COPS: 0
OK I have a IDEA sim
Run Code Online (Sandbox Code Playgroud)
让我知道是什么问题。我正在使用大约 4 v 的电流。可以吗?
我想知道以下哪两行更有效:
db.run(events (..filter/sort..) .take(1).result.head)
Run Code Online (Sandbox Code Playgroud)
要么
db.run(events (..filter/sort..) .result.head)
Run Code Online (Sandbox Code Playgroud)
正如我发现.take来自slick.lifted.Query
和.head来自slick.profile.BasicStreamingAction