Send exception mail once 3 retry from queue has been exhausted

I was searching for this solution but could not find it on forum so I have solved it and putting the solution.

So we have use the transactionitem.retyno or we can assign transactionitem.retryno to retry number variable

In process workflow in catch exception block we can use if condition and put like transactionitem.retryno>=3 in case if you have put max retry as 3 in queue this will solve the problem and once condition is satisfied you can send the exception mails to client