Hystrix and Spring transactions

946 views
Skip to first unread message

AJ

unread,
Apr 2, 2014, 11:50:19 PM4/2/14
to hystr...@googlegroups.com
Hi,

I'm implementing Hystrix within my rest services layer, that calls multiple services that include read/write Database operations as well as calling third party services.
I'm using spring DatasourceTransactionManager to manage transactions. However, transaction are not working. 

I know the DatasourceTransactionManager is a local transaction manager and may not be able to sync up all the multiple threads that Hystrix spawns.

So just wanted to know whether an application server level Transaction manager would resolve this issue, or is there anything else that i need to do. Has anyone else, had this issue.

Pls advice.

Thanks 
AJ

Ben Christensen

unread,
Apr 3, 2014, 12:19:22 PM4/3/14
to hystr...@googlegroups.com, AJ
I am not familiar with Spring so can’t help with that specifically. If different threads are involved though, that generally means you need to manage thread context yourself. 

You may need to implement a ConcurrencyStrategy plugin, here are some places to look:


-- 
Ben Christensen - Netflix Edge Engineering
+1.310.782.5511  @benjchristensen
--
You received this message because you are subscribed to the Google Groups "HystrixOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hystrixoss+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johnson Ashish Joseph

unread,
Apr 3, 2014, 1:38:23 PM4/3/14
to Ben Christensen, hystr...@googlegroups.com
Thanks for replying. 

But the thing that I wanted to know was that since I'm asynchronously calling multiple hystrix commands for third party and database write operation calls, how can I ensure that all the hystrix threads remain in the same transaction as the main thread. 

Thanks
AJ


--
Sent from Gmail Mobile

Ben Christensen

unread,
Apr 3, 2014, 3:54:24 PM4/3/14
to Ben Christensen, Johnson Ashish Joseph, hystr...@googlegroups.com
I don’t know how your transaction manager works, but if it’s based on thread context, you can implement the HystrixConcurrencyStrategy and HystrixRequestContext to make sure the HystrixCommand executions copy thread state from the thread where they are invoked and thus work within the transaction.

-- 
Ben Christensen
+1.310.782.5511  @benjchristensen
Reply all
Reply to author
Forward
0 new messages