exception handling in int-jpa:updating-outbound-gateway

谁都会走 提交于 2020-03-27 05:39:36

问题


i have a code

<int-jpa:updating-outbound-gateway 
			auto-startup="true"
			native-query="update Transactions t set t.transaction_Status =   :transactionStatus 
 		where t.bank_Reference_Number = :bankReferenceNumber "
			entity-manager="entityManager" persist-mode="PERSIST"
			use-payload-as-parameter-source="false">
			<int-jpa:transactional />
			<int-jpa:parameter name="transactionStatus" 		expression="payload['transactionStatus']" />
			<int-jpa:parameter name="bankReferenceNumber"		expression="payload['bankReferenceNumber']" />

</int-jpa:updating-outbound-gateway>

i want to add error channel , so that if some exception occurs i can see that.


回答1:


The error-channel is for flows which works independently of the user: Message Driven Channel Adapter, e.g. <int-jms:message-driven-channel-adapter>, where an Listener Container is started in the infinite loop and does its work actively.

Another sample is Polling Consumer, which runs the polling task periodically, e.g. <int-file:inbound-channel-adapter>, or anyone as a consumer on the QueueChannel. And again: it does that actively, independently of your existence.

The <int-jpa:updating-outbound-gateway> is passive component, therefore it can't do anything until you send a message. Therefore any error caused in this kind of components are thrown to the caller, like it is done in the raw Java method invocation.

Read more about error handling in the Reference Manual.

For your use-case you should consider to add error-channel in the upstream poller if that.

Another case is ExpressionEvaluatingRequestHandlerAdvice, which with its failureChannel may play some kind of error handling for the particular MessageHandler.




回答2:


The error channel goes on some upstream component (usually whatever starts the flow).

An alternative is to add and ExpressionEvaluatingAdvice to the gateway; see the reference manual.



来源:https://stackoverflow.com/questions/39915579/exception-handling-in-int-jpaupdating-outbound-gateway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!