2

I have a basic doubt regarding Transactions and the HornetQ native API.

If my application is Spring-based, with Spring managed transactions, how should I configure HornetQ to participate in the same transaction managed by Spring (AOP)?

Using the JMS API I guess it's fairly obvious, since Spring considers JMS resources as transactional.

But I don't know how to do it correctly using the nativa API. Could someone shed a light on this problem?

Many thanks!

2 Answers 2

1

HornetQ supports XA on the core API, they are just resources.

You should be able to enlist these resources on Spring if that's just using regular XA API.

http://docs.jboss.org/hornetq/2.2.5.Final/api/org/hornetq/api/core/client/ClientSession.html

I'm not sure though how that integration is done on Spring. If there's anything not working it could (and should) be fixed or improved on a spring-integration module.

1

Not sure if I understand correctly, but if you're trying to simply do declarative transaction managment using Spring and the @Transactional annotation for JUST JMS, then simply use the <tx:annotation-driven transaction-manager = "myTransactionManager" /> and then - for the "myTranactionManager," register a bean of type JmsTransactionManager, e.g.,

@Bean public PlatformTransactionManager myTranactionManager (){ 
  return new JmsTransactionManager( this.connectionFactory());
} 

Now, you can use the annotation as normal and the JMS interactions will be wrapped in a transaction

@Transactional
public void doSomethingWithJms(){ 
  jmsTemplate.send(...);
  jmsTemplate.convertAndSend(...)
}

If your goal is to work with MULTIPLE resources, e.g., JMS and JDBC, then you need to use JTA. To see how to setup JTA (for JPA and JMS), check out this blog post http://blog.springsource.com/2011/08/15/configuring-spring-and-jta-without-full-java-ee/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.