Error records at work and errors at work
1. An error may occur when a program calls the message sending interface in the project, affecting the main program's process;
Solution: (1) mq sends messages
(2) The message sending interface itself captures and handles exceptions and cannot throw them to the main program.
Now we can implement the second solution: because exceptions were thrown by all previous message sending nodes, it would be very troublesome to add Exception Processing to each method. Now we use @ Aspect provided by spring to implement it;
Note the following when using it:
<1> <context: component-scan/> by default, the annotation @ Aspect is not scanned. You need to add the @ Comment annotation or include in xml to the class.
<2> @ AfterThrowing
@ Around try catch does not continue to throw an exception
<3> reference: http://blog.csdn.net/confirmaname/article/details/9728327
2When calling a method
Transaction rolled back because it has been marked as rollback-onlyException
Code Restoration:
(1)
Class xx {
Method (){
B ();
}
}
(2) Configuration
Method a belongs to: <tx: method name = "update *" propagation = "REQUIRED" read-only = "false" rollback-for = "Exception"/>
Method B: <tx: method name = "*" read-only = "true"/>
Cause: When method a calls Method B, Method B encounters an exception, but it is caught and not thrown. In this case, Method B uses a transaction with method a because it is the default (REQUIRED) in the configuration. If an exception occurs in Method B, the transaction is marked and method a continues, this exception occurs when the transaction is committed before the end method.
Solution: Because Method B is the query method, Set Method B to NOT_SUPPORTED.
Reference connection: http://blog.csdn.net/launch_225/article/details/7814346
Http://blog.sina.com.cn/s/blog_4a40057401000865.html