You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by macdoor <xd...@bj1860.net> on 2006/12/19 15:44:09 UTC
Can I forward transaction with EIP component?
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.
Re: Can I forward transaction with EIP component?
Posted by macdoor <xd...@bj1860.net>.
Thx, I will try it, and I will post it tomorrow.
gnodet wrote:
>
> Try to put log level at debug for everything.
> You should see when transactions are suspended / resumed.
>
> On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>>
>> I use apache-servicemix-3.1-incubating-20061116.072011-9.tar.gz
>>
>> I use two JMS, JMS client(standalone app) ->JMS/JCA consumer-> EIP -> JMS
>> Provider
>>
>>
>>
>>
>> gnodet wrote:
>> >
>> > The JMS is used as the transformer or the target for the pipeline ?
>> > And do you use ServiceMix 3.1-SNAPSHOT ?
>> >
>> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >>
>> >> I set <eip:pipeline service="zznode:tojpa" endpoint="endpoint">
>> >>
>> >>
>> >>
>> >> gnodet wrote:
>> >> >
>> >> > There's no need to do anything.
>> >> > When the component receives a transacted exchange, it will
>> >> > resume the thread using the transaction manager. If an exchange
>> >> > is sent while the transaction is active, the
>> autoEnlistInTransactions
>> >> > flag will ensure that the transaction is conveyed by the exchange
>> >> > sent (the transaction will be suspended, handled by the provider
>> >> > and resumed when the sendSync call return).
>> >> > All the needed code is in AsyncBaseLifeCycle [1] and
>> >> DeliveryChannelImpl
>> >> > [2]
>> >> >
>> >> > Btw, which EIP endpoint do you use ?
>> >> >
>> >> > [1]
>> >> >
>> >>
>> http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
>> >> > [2]
>> >> >
>> >>
>> http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
>> >> >
>> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >> >>
>> >> > r> Yes, I have set the autoEnlistInTransactions="true" flag on the
>> JBI
>> >> > container
>> >> >> .
>> >> >>
>> >> >> I also and some test code in EIP component (pipeline) and JMS
>> provider
>> >> >> component to System.out.println( exchange.isTransacted())
>> >> >>
>> >> >> I found in EIP exchange.isTransacted() is true and in next JMS
>> >> provider
>> >> >> exchange.isTransacted() is false.
>> >> >>
>> >> >> I found in EIP pipeline code
>> >> >>
>> >>
>> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
>> >> >>
>> >> >> /* (non-Javadoc)
>> >> >> * @see
>> >> >>
>> >>
>> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
>> >> >> */
>> >> >> protected void processSync(MessageExchange exchange) throws
>> >> Exception
>> >> >> {
>> >> >> ...
>> >> >>
>> >> >> MessageExchange me =
>> >> >> getExchangeFactory().createExchange(exchange.getPattern());
>> >> >> (faultsTarget != null ? faultsTarget :
>> >> >> target).configureTarget(me, getContext());
>> >> >> MessageUtil.transferToIn(tme.getFault(), me);
>> >> >> sendSync(me);
>> >> >>
>> >> >> It create a new exchange. Shall we set the transactionmanager in
>> the
>> >> new
>> >> >> exchange?
>> >> >>
>> >> >>
>> >> >> gnodet wrote:
>> >> >> >
>> >> >> > Have you set the autoEnlistInTransactions="true" flag on the JBI
>> >> >> container
>> >> >> > ?
>> >> >> > Else no transaction propagation will occur ...
>> >> >> > I'm pondering changing the default value to true ...
>> >> >> >
>> >> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >> >> >>
>> >> >> >> 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.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Cheers,
>> >> >> > Guillaume Nodet
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
>> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Cheers,
>> >> > Guillaume Nodet
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948792
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948965
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7949169
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Can I forward transaction with EIP component?
Posted by Guillaume Nodet <gn...@gmail.com>.
Try to put log level at debug for everything.
You should see when transactions are suspended / resumed.
On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>
> I use apache-servicemix-3.1-incubating-20061116.072011-9.tar.gz
>
> I use two JMS, JMS client(standalone app) ->JMS/JCA consumer-> EIP -> JMS
> Provider
>
>
>
>
> gnodet wrote:
> >
> > The JMS is used as the transformer or the target for the pipeline ?
> > And do you use ServiceMix 3.1-SNAPSHOT ?
> >
> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >>
> >> I set <eip:pipeline service="zznode:tojpa" endpoint="endpoint">
> >>
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > There's no need to do anything.
> >> > When the component receives a transacted exchange, it will
> >> > resume the thread using the transaction manager. If an exchange
> >> > is sent while the transaction is active, the autoEnlistInTransactions
> >> > flag will ensure that the transaction is conveyed by the exchange
> >> > sent (the transaction will be suspended, handled by the provider
> >> > and resumed when the sendSync call return).
> >> > All the needed code is in AsyncBaseLifeCycle [1] and
> >> DeliveryChannelImpl
> >> > [2]
> >> >
> >> > Btw, which EIP endpoint do you use ?
> >> >
> >> > [1]
> >> >
> >> http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
> >> > [2]
> >> >
> >> http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
> >> >
> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >> >>
> >> > r> Yes, I have set the autoEnlistInTransactions="true" flag on the JBI
> >> > container
> >> >> .
> >> >>
> >> >> I also and some test code in EIP component (pipeline) and JMS provider
> >> >> component to System.out.println( exchange.isTransacted())
> >> >>
> >> >> I found in EIP exchange.isTransacted() is true and in next JMS
> >> provider
> >> >> exchange.isTransacted() is false.
> >> >>
> >> >> I found in EIP pipeline code
> >> >>
> >> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
> >> >>
> >> >> /* (non-Javadoc)
> >> >> * @see
> >> >>
> >> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
> >> >> */
> >> >> protected void processSync(MessageExchange exchange) throws
> >> Exception
> >> >> {
> >> >> ...
> >> >>
> >> >> MessageExchange me =
> >> >> getExchangeFactory().createExchange(exchange.getPattern());
> >> >> (faultsTarget != null ? faultsTarget :
> >> >> target).configureTarget(me, getContext());
> >> >> MessageUtil.transferToIn(tme.getFault(), me);
> >> >> sendSync(me);
> >> >>
> >> >> It create a new exchange. Shall we set the transactionmanager in the
> >> new
> >> >> exchange?
> >> >>
> >> >>
> >> >> gnodet wrote:
> >> >> >
> >> >> > Have you set the autoEnlistInTransactions="true" flag on the JBI
> >> >> container
> >> >> > ?
> >> >> > Else no transaction propagation will occur ...
> >> >> > I'm pondering changing the default value to true ...
> >> >> >
> >> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >> >> >>
> >> >> >> 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.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Cheers,
> >> >> > Guillaume Nodet
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948792
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948965
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
Re: Can I forward transaction with EIP component?
Posted by macdoor <xd...@bj1860.net>.
I use apache-servicemix-3.1-incubating-20061116.072011-9.tar.gz
I use two JMS, JMS client(standalone app) ->JMS/JCA consumer-> EIP -> JMS
Provider
gnodet wrote:
>
> The JMS is used as the transformer or the target for the pipeline ?
> And do you use ServiceMix 3.1-SNAPSHOT ?
>
> On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>>
>> I set <eip:pipeline service="zznode:tojpa" endpoint="endpoint">
>>
>>
>>
>> gnodet wrote:
>> >
>> > There's no need to do anything.
>> > When the component receives a transacted exchange, it will
>> > resume the thread using the transaction manager. If an exchange
>> > is sent while the transaction is active, the autoEnlistInTransactions
>> > flag will ensure that the transaction is conveyed by the exchange
>> > sent (the transaction will be suspended, handled by the provider
>> > and resumed when the sendSync call return).
>> > All the needed code is in AsyncBaseLifeCycle [1] and
>> DeliveryChannelImpl
>> > [2]
>> >
>> > Btw, which EIP endpoint do you use ?
>> >
>> > [1]
>> >
>> http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
>> > [2]
>> >
>> http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
>> >
>> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >>
>> > r> Yes, I have set the autoEnlistInTransactions="true" flag on the JBI
>> > container
>> >> .
>> >>
>> >> I also and some test code in EIP component (pipeline) and JMS provider
>> >> component to System.out.println( exchange.isTransacted())
>> >>
>> >> I found in EIP exchange.isTransacted() is true and in next JMS
>> provider
>> >> exchange.isTransacted() is false.
>> >>
>> >> I found in EIP pipeline code
>> >>
>> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
>> >>
>> >> /* (non-Javadoc)
>> >> * @see
>> >>
>> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
>> >> */
>> >> protected void processSync(MessageExchange exchange) throws
>> Exception
>> >> {
>> >> ...
>> >>
>> >> MessageExchange me =
>> >> getExchangeFactory().createExchange(exchange.getPattern());
>> >> (faultsTarget != null ? faultsTarget :
>> >> target).configureTarget(me, getContext());
>> >> MessageUtil.transferToIn(tme.getFault(), me);
>> >> sendSync(me);
>> >>
>> >> It create a new exchange. Shall we set the transactionmanager in the
>> new
>> >> exchange?
>> >>
>> >>
>> >> gnodet wrote:
>> >> >
>> >> > Have you set the autoEnlistInTransactions="true" flag on the JBI
>> >> container
>> >> > ?
>> >> > Else no transaction propagation will occur ...
>> >> > I'm pondering changing the default value to true ...
>> >> >
>> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >> >>
>> >> >> 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.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Cheers,
>> >> > Guillaume Nodet
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948792
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948965
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Can I forward transaction with EIP component?
Posted by Guillaume Nodet <gn...@gmail.com>.
The JMS is used as the transformer or the target for the pipeline ?
And do you use ServiceMix 3.1-SNAPSHOT ?
On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>
> I set <eip:pipeline service="zznode:tojpa" endpoint="endpoint">
>
>
>
> gnodet wrote:
> >
> > There's no need to do anything.
> > When the component receives a transacted exchange, it will
> > resume the thread using the transaction manager. If an exchange
> > is sent while the transaction is active, the autoEnlistInTransactions
> > flag will ensure that the transaction is conveyed by the exchange
> > sent (the transaction will be suspended, handled by the provider
> > and resumed when the sendSync call return).
> > All the needed code is in AsyncBaseLifeCycle [1] and DeliveryChannelImpl
> > [2]
> >
> > Btw, which EIP endpoint do you use ?
> >
> > [1]
> > http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
> > [2]
> > http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
> >
> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >>
> > r> Yes, I have set the autoEnlistInTransactions="true" flag on the JBI
> > container
> >> .
> >>
> >> I also and some test code in EIP component (pipeline) and JMS provider
> >> component to System.out.println( exchange.isTransacted())
> >>
> >> I found in EIP exchange.isTransacted() is true and in next JMS provider
> >> exchange.isTransacted() is false.
> >>
> >> I found in EIP pipeline code
> >> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
> >>
> >> /* (non-Javadoc)
> >> * @see
> >> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
> >> */
> >> protected void processSync(MessageExchange exchange) throws Exception
> >> {
> >> ...
> >>
> >> MessageExchange me =
> >> getExchangeFactory().createExchange(exchange.getPattern());
> >> (faultsTarget != null ? faultsTarget :
> >> target).configureTarget(me, getContext());
> >> MessageUtil.transferToIn(tme.getFault(), me);
> >> sendSync(me);
> >>
> >> It create a new exchange. Shall we set the transactionmanager in the new
> >> exchange?
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > Have you set the autoEnlistInTransactions="true" flag on the JBI
> >> container
> >> > ?
> >> > Else no transaction propagation will occur ...
> >> > I'm pondering changing the default value to true ...
> >> >
> >> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >> >>
> >> >> 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.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948792
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
Re: Can I forward transaction with EIP component?
Posted by macdoor <xd...@bj1860.net>.
I set <eip:pipeline service="zznode:tojpa" endpoint="endpoint">
gnodet wrote:
>
> There's no need to do anything.
> When the component receives a transacted exchange, it will
> resume the thread using the transaction manager. If an exchange
> is sent while the transaction is active, the autoEnlistInTransactions
> flag will ensure that the transaction is conveyed by the exchange
> sent (the transaction will be suspended, handled by the provider
> and resumed when the sendSync call return).
> All the needed code is in AsyncBaseLifeCycle [1] and DeliveryChannelImpl
> [2]
>
> Btw, which EIP endpoint do you use ?
>
> [1]
> http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
> [2]
> http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
>
> On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>>
> r> Yes, I have set the autoEnlistInTransactions="true" flag on the JBI
> container
>> .
>>
>> I also and some test code in EIP component (pipeline) and JMS provider
>> component to System.out.println( exchange.isTransacted())
>>
>> I found in EIP exchange.isTransacted() is true and in next JMS provider
>> exchange.isTransacted() is false.
>>
>> I found in EIP pipeline code
>> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
>>
>> /* (non-Javadoc)
>> * @see
>> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
>> */
>> protected void processSync(MessageExchange exchange) throws Exception
>> {
>> ...
>>
>> MessageExchange me =
>> getExchangeFactory().createExchange(exchange.getPattern());
>> (faultsTarget != null ? faultsTarget :
>> target).configureTarget(me, getContext());
>> MessageUtil.transferToIn(tme.getFault(), me);
>> sendSync(me);
>>
>> It create a new exchange. Shall we set the transactionmanager in the new
>> exchange?
>>
>>
>> gnodet wrote:
>> >
>> > Have you set the autoEnlistInTransactions="true" flag on the JBI
>> container
>> > ?
>> > Else no transaction propagation will occur ...
>> > I'm pondering changing the default value to true ...
>> >
>> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>> >>
>> >> 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.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948792
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Can I forward transaction with EIP component?
Posted by Guillaume Nodet <gn...@gmail.com>.
There's no need to do anything.
When the component receives a transacted exchange, it will
resume the thread using the transaction manager. If an exchange
is sent while the transaction is active, the autoEnlistInTransactions
flag will ensure that the transaction is conveyed by the exchange
sent (the transaction will be suspended, handled by the provider
and resumed when the sendSync call return).
All the needed code is in AsyncBaseLifeCycle [1] and DeliveryChannelImpl [2]
Btw, which EIP endpoint do you use ?
[1] http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?r=484814
[2] http://fisheye3.cenqua.com/browse/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?r=482795
On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>
r> Yes, I have set the autoEnlistInTransactions="true" flag on the JBI container
> .
>
> I also and some test code in EIP component (pipeline) and JMS provider
> component to System.out.println( exchange.isTransacted())
>
> I found in EIP exchange.isTransacted() is true and in next JMS provider
> exchange.isTransacted() is false.
>
> I found in EIP pipeline code
> http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
>
> /* (non-Javadoc)
> * @see
> org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
> */
> protected void processSync(MessageExchange exchange) throws Exception {
> ...
>
> MessageExchange me =
> getExchangeFactory().createExchange(exchange.getPattern());
> (faultsTarget != null ? faultsTarget :
> target).configureTarget(me, getContext());
> MessageUtil.transferToIn(tme.getFault(), me);
> sendSync(me);
>
> It create a new exchange. Shall we set the transactionmanager in the new
> exchange?
>
>
> gnodet wrote:
> >
> > Have you set the autoEnlistInTransactions="true" flag on the JBI container
> > ?
> > Else no transaction propagation will occur ...
> > I'm pondering changing the default value to true ...
> >
> > On 12/19/06, macdoor <xd...@bj1860.net> wrote:
> >>
> >> 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.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
Re: Can I forward transaction with EIP component?
Posted by macdoor <xd...@bj1860.net>.
Yes, I have set the autoEnlistInTransactions="true" flag on the JBI container
.
I also and some test code in EIP component (pipeline) and JMS provider
component to System.out.println( exchange.isTransacted())
I found in EIP exchange.isTransacted() is true and in next JMS provider
exchange.isTransacted() is false.
I found in EIP pipeline code
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/Pipeline.java?revision=488681&view=markup
/* (non-Javadoc)
* @see
org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
*/
protected void processSync(MessageExchange exchange) throws Exception {
...
MessageExchange me =
getExchangeFactory().createExchange(exchange.getPattern());
(faultsTarget != null ? faultsTarget :
target).configureTarget(me, getContext());
MessageUtil.transferToIn(tme.getFault(), me);
sendSync(me);
It create a new exchange. Shall we set the transactionmanager in the new
exchange?
gnodet wrote:
>
> Have you set the autoEnlistInTransactions="true" flag on the JBI container
> ?
> Else no transaction propagation will occur ...
> I'm pondering changing the default value to true ...
>
> On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>>
>> 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.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context: http://www.nabble.com/Can-I-forward-transaction-with-EIP-component--tf2846280s12049.html#a7948441
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Can I forward transaction with EIP component?
Posted by Guillaume Nodet <gn...@gmail.com>.
Have you set the autoEnlistInTransactions="true" flag on the JBI container ?
Else no transaction propagation will occur ...
I'm pondering changing the default value to true ...
On 12/19/06, macdoor <xd...@bj1860.net> wrote:
>
> 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.
>
>
--
Cheers,
Guillaume Nodet