Greetings, we are running Camel routes in JBoss AS7 and the problem I ran
into is that there is no transaction manager initialized to work with the
transacted routes. In my test code I did something like the following:

  @Override

  protected CamelContext createCamelContext() throws Exception {

    final SimpleRegistry registry = new SimpleRegistry();

    final CamelContext context = new DefaultCamelContext(registry);


    final BrokerService broker = getAMQBroker();

    final ActiveMQConnectionFactory amqcf =
newActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getUri());


    final PlatformTransactionManager txMgr = newJmsTransactionManager(amqcf);

    registry.put("transactionManager", txMgr);


    final SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();

    txPolicy.setTransactionManager(txMgr);

    txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");

    registry.put("required", txPolicy);


    final ActiveMQComponent amq = (ActiveMQComponent) context.getComponent(
"activemq");

    amq.setConnectionFactory(amqcf);

    return context;

  }


I tried the same thing in the Lifecycle class:

  @Override

  public void beforeStart(final ServletCamelContext context,
finalJndiRegistry registry)
throws Exception {

    final ActiveMQConnectionFactory amqcf = (ActiveMQConnectionFactory)
registry.lookup("java:/activemq/ConnectionFactory");

    final PlatformTransactionManager txMgr = newJmsTransactionManager(amqcf);

    registry.bind("camel-transactionManager", txMgr);


    final SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();

    txPolicy.setTransactionManager(txMgr);

    txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");

    registry.bind("required", txPolicy);

  }

The similar code in the CamelContextLifecycle didn't work because Camel
does a findByTypeWithName on the registry when looking for a transaction
manager and if you dig into 2.11.1 code findByType for the JNDIRegistry
eventually leads you to a method that returns an empty map.

    public <T> Map<String, T> findByTypeWithName(Class<T> type) {

        // not implemented so we return an empty map

        return Collections.emptyMap();

    }

As you can see this find will never work so as a result I get the error
that there is no platform transaction manager whenever I use a transacted
route.

Furthermore spring is off the table due to people here who hate spring and
cannot be shifted on that and have the power to make those decisions. So
how do I initialize a transaction manager for transacted routes in this
circumstance?

All help is appreciated.

Reply via email to