[[Sry about the badly formatted post - hope this is better]]
Ok, I've fiddled and got something running - not fully tested yet :)
Any comments are appreciated. If it's sound, could this be added to
camel-cdi ? Or at least documented og added as an example ?
@Named("transactionManager")
public class CdiJtaTransactionManager extends JtaTransactionManager {
@Resource(lookup = "java:jboss/TransactionManager")
private TransactionManager transactionManager;
@Resource
private UserTransaction userTransaction;
public CdiJtaTransactionManager() {
super();
}
@PostConstruct
public void setManager() {
setTransactionManager(transactionManager);
setUserTransaction(userTransaction);
}
}
@Named("PROPAGATION_REQUIRED")
public class CdiRequiredPolicy extends SpringTransactionPolicy {
@Inject
public CdiRequiredPolicy(CdiJtaTransactionManager
cdiJtaTransactionManager) {
super(new TransactionTemplate(cdiJtaTransactionManager, new
DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED)));
}
}
@Singleton
@Startup
public class CamelBootstrap {
@Inject
private CdiCamelContext camelCtx;
@Resource(mappedName = "java:/JmsXA")
private ConnectionFactory connectionFactory;
camelCtx.addComponent("jms",
JmsComponent.jmsComponentTransacted(connectionFactory));
Now I can configure a JMS-route starting like this:
from("jms:queue:Nemhandel_Leverandoer_Inbound")
.transacted("PROPAGATION_REQUIRED")
--
View this message in context:
http://camel.465427.n5.nabble.com/Transacted-Apache-Camel-Route-with-CDI-in-AS7-tp5751824p5751873.html
Sent from the Camel - Users mailing list archive at Nabble.com.