@Craig

That's more for an OptimisticLockException when I write to a NoSql Db.

I explain :

I would annotate the method with something like 
@RetryOnOptimisticLockingException(retryCount) 

The content of the method will be something like this:

I read the row. I change it and after I save the change in the db. If 
another thread updated the db, I need to read the row, change it and save 
the change in the db and repeat it until there's no other thread that 
insert into the row.

I could also create a while with a count in every method that need to 
update a row in the db but I thought it'll be cleaner this way.


I also found this technique:  
http://fahdshariff.blogspot.ca/2009/08/retrying-operations-in-java.html 
I don't know if I'll choose AOP or Task...

On Wednesday, June 6, 2012 1:40:14 AM UTC-4, Craig McClanahan wrote:
>
> I can't help but shudder at how few classes you wrap might actually be 
> prepared to deal with this kind of voodoo.  IMHO, uses of AOP should 
> focused on cross cutting concerns like transactional processing and 
> logging, not changing the fundamental processing flow of the underlying 
> application.  Otherwise, how in the world are you going to be able to write 
> tests and believe in your coverage metrics?
>
> Craig McClanahan
>
> On Tue, Jun 5, 2012 at 2:48 PM, Bob Lee <[email protected]> wrote:
>
>> Yep, that should work.
>>
>> Bob
>>
>>
>> On Tue, Jun 5, 2012 at 1:54 PM, JavaPlayer <[email protected]> wrote:
>>
>>> I would like to create a retry mechanism with Guice AOP. I wanted to 
>>> know if it's legal to call proceed() multiple time in the same 
>>> invoke(MethodInvocation invocation). Otherwise, is there a better way to 
>>> implement a retry mechanism on many different method in my application. 
>>>
>>>
>>> I would like to do something like:
>>>
>>> public Object invoke(MethodInvocation invocation) throws Throwable {
>>>              boolean success = false;
>>>               while(!success){
>>>               try{
>>> invocation.proceed();
>>>                 success = true;
>>>               catch(MyCustomException e){
>>>                   success = false;
>>>               }
>>>         }
>>>
>>> }
>>>
>>> Thank you
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "google-guice" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/google-guice/-/2wf2SoWqvzAJ.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group at 
>>> http://groups.google.com/group/google-guice?hl=en.
>>>
>>
>>
>>
>> -- 
>> Bob
>> Square is hiring! <https://squareup.com/jobs>
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "google-guice" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/google-guice?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/h7D6oUzReEUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to