Error records at work and errors at work

Source: Internet
Author: User

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

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.