I start a transaction with JMS/JCA component, and send the message to an EIP
component, after EIP transaction disappear. Is it the right behavior?

The flow is like this, JMS/JCA->EIP->JMS. There is no transction in last JMS
component.

I read the source
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/EIPEndpoint.java?revision=488681&view=markup

    public void process(MessageExchange exchange) throws Exception {
        boolean txSync = exchange.isTransacted() &&
Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
        if (txSync && exchange.getRole() == Role.PROVIDER &&
exchange.getStatus() == ExchangeStatus.ACTIVE) {
            processSync(exchange);
        } else {
            processAsync(exchange);
        }
    }

There is no code to handle transaction. 

But in
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/jca/JcaConsumerProcessor.java?revision=478801&view=markup.

    public void process(MessageExchange exchange) throws Exception {
        Context context = (Context)
pendingMessages.remove(exchange.getExchangeId());
        Message message = (Message)
context.getProperty(Message.class.getName());
        Message response = null;
        Connection connection = null;
        try {
            if (exchange.getStatus() == ExchangeStatus.DONE) {
                return;
            } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
                if (endpoint.isRollbackOnError()) {
                    TransactionManager tm = (TransactionManager)
endpoint.getServiceUnit().getComponent().getComponentContext().getTransactionManager();
                    tm.setRollbackOnly();
                    return;
                } else if (exchange instanceof InOnly) {
                    log.info("Exchange in error: " + exchange,
exchange.getError());
                    return;
                } else {
                    connection = connectionFactory.createConnection();
                    Session session = connection.createSession(true,
Session.SESSION_TRANSACTED);
                    Exception error = exchange.getError();
                    if (error == null) {
                        error = new Exception("Exchange in error");
                    }
                    response = session.createObjectMessage(error);
                    MessageProducer producer =
session.createProducer(message.getJMSReplyTo());
                    if (endpoint.isUseMsgIdInResponse()) {
                       
response.setJMSCorrelationID(message.getJMSMessageID());
                    } else {
                       
response.setJMSCorrelationID(message.getJMSCorrelationID());
                    }
                    producer.send(response);
                }
            } else {
                connection = connectionFactory.createConnection();
                Session session = connection.createSession(true,
Session.SESSION_TRANSACTED);
                response = fromNMSResponse(exchange, context, session);
                if (response != null) {
                    MessageProducer producer =
session.createProducer(message.getJMSReplyTo());
                    if (endpoint.isUseMsgIdInResponse()) {
                       
response.setJMSCorrelationID(message.getJMSMessageID());
                    } else {
                       
response.setJMSCorrelationID(message.getJMSCorrelationID());
                    }
                    producer.send(response);
                }
            }
        } finally {
            if (connection != null) {
                connection.close();
            }
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                exchange.setStatus(ExchangeStatus.DONE);
                channel.send(exchange);
            }
        }
    }

It has code to forward transaction.

Can I add the same code to EIP and let EIP can forward transaction?





-- 
View this message in context: 
http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948174
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to