I am having issues posting my message to forum for last 2 days
Now I am trying posting it here, as it is related to this thread. Though I
have created a new thread to post my message but was unsuccessful. Please
someone help my below transaction issue with servicemix 4
Please suggest, it is urgent
Hi ,
I am using apache-servicemix-4.0.0. My flow is jms consumer->eip(pipeline)
eip pipeline has a bean class as transformer and http provider as target. I
am starting a transaction in jms consumer. here is my xbean.xml files
<jms:endpoint id="eipjmsconsumer"
service="ec:jms"
endpoint="jms"
targetService="ec:eip"
targetEndpoint="eip"
role="consumer"
processorName="jca"
defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
connectionFactory="#connectionFactory"
synchronous="true"
resourceAdapter="#amqResourceAdapter"
bootstrapContext="#bootstrapContext"
rollbackOnError="true">
<jms:activationSpec>
<amqra:activationSpec destination="epq1"
destinationType="javax.jms.Queue"
maximumRedeliveries="2"
initialRedeliveryDelay="10000"
useExponentialBackOff="false" />
</jms:activationSpec>
</jms:endpoint>
<bean id="bootstrapContext"
class="org.jencks.factory.BootstrapContextFactoryBean">
<property name="threadPoolSize" value="15" />
<property name="transactionManager"
ref="transactionManager"/>
</bean>
<amqra:resourceAdapter id="amqResourceAdapter"
serverUrl="tcp://localhost:61616" />
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="transactionManager"
class="org.apache.geronimo.transaction.manager.GeronimoTransactionManager"></bean>
<!--amq works
<amq:connectionFactory id="connectionFactory"
brokerURL="tcp://localhost:61616" />
JMS ConnectionFactory from JNDI - <bean
id="connectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property
name="jndiName" value="ConnectionFactory" /> </bean>
-->
</beans>
<eip:pipeline service="ec:eip" endpoint="eip">
<eip:transformer>
<eip:exchange-target service="ec:bean" />
</eip:transformer>
<eip:target>
<eip:exchange-target service="ec:http" />
</eip:target>
</eip:pipeline>
<bean:endpoint service="ec:bean" endpoint="bean" bean="#myBean"/>
<bean id="myBean" class="com.pf.eipconsumer.RouterBean"/>
</beans>
<http:endpoint service="ec:http"
endpoint="http"
role="provider"
locationURI="http://localhost/orderapp/OrderProcess1"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
/>
</beans>
here is my bean class file. In this class file I am parsing soap header to
set the http location URI at run time
public class RouterBean implements MessageExchangeListener {
@Resource
private DeliveryChannel channel;
private static final org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory
.getLog(RouterBean.class);
public void onMessageExchange(MessageExchange exchange)
throws MessagingException {
log.info("Received exchange: " + exchange);
log.info("Received exchange status: " +
exchange.getStatus());
log.info("Received exchange:properties");
Iterator<String> iterator2 =
exchange.getPropertyNames().iterator();
while (iterator2.hasNext()) {
String propName2 = iterator2.next();
log.info("inside iterator,propName:" + propName2 +
":"
+ exchange.getProperty(propName2));
}
String body = null;
try {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
NormalizedMessage message =
exchange.getMessage("in");
Source content = message.getContent();
log.info("content is:" + content);
body = (new
SourceTransformer()).toString(content);
log.info("eipConsumer:input message body
is:" + body);
message.setContent(new StringSource(body));
exchange.setMessage(message, "out");
String uri = getURIFromMessage(body);
log.info("uri is:"+uri);
boolean useDynamicUri = true;
if (useDynamicUri) {
exchange.getMessage("out").setProperty(
JbiConstants.HTTP_DESTINATION_URI,
uri);
}
boolean good = channel.sendSync(exchange);
log.info("channel send done");
//else if(exchange.getStatus() ==
ExchangeStatus.DONE){
if(good){
log.info("inside DONE block");
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
}
//else if(exchange.getStatus() ==
ExchangeStatus.ERROR){
else{
log.info("inside ERROR block");
//Exception ex = new Exception ("ERROR:Fault
occurred"+faultbody);
Exception ex = new Exception ("ERROR:Fault
occurred");
exchange.setError(ex);
exchange.setStatus(ExchangeStatus.ERROR);
channel.send(exchange);
}
}
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error("error:", e);
} finally {
// exchange.setStatus(ExchangeStatus.DONE);
// channel.send(exchange);
}
}
I am getting exception as below. Please suggest what am I doing wrong here
2010-04-19 22:14:37,078| 22:14:37,078 | INFO | x-bean-thread-12 |
RouterBean | com.pf.eipconsumer.RouterBean 66 |
uri is:http://LPF004689/orderapp/OrderProcess
2010-04-19 22:14:37,078| 22:14:37,078 | ERROR | mix-eip-thread-5 |
EIPComponent | icemix.common.AsyncBaseLifeCycle 480 |
Error processing exchange
org.apache.servicemix.jbi.runtime.impl.inonlyi...@8d1aa8
javax.jbi.messaging.MessagingException:
javax.transaction.InvalidTransactionException: Specified transaction is
already associated with another thread at
org.apache.servicemix.common.EndpointDeliveryChannel.resumeTx(EndpointDeliveryChannel.java:137)
at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:118)
at
org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
at
org.apache.servicemix.eip.patterns.Pipeline.processSync(Pipeline.java:246)
at
org.apache.servicemix.eip.EIPEndpoint.process(EIPEndpoint.java:183)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)
at
org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.transaction.InvalidTransactionException: Specified
transaction is already associated with another thread
at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.associate(TransactionManagerImpl.java:114)
at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.resume(TransactionManagerImpl.java:183)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:64)
at
org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:78)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy23.resume(Unknown Source)
at
org.apache.servicemix.common.EndpointDeliveryChannel.resumeTx(EndpointDeliveryChannel.java:135)
... 11 more
2010-04-19 22:14:37,078| 22:14:37,078 | ERROR | ix-http-thread-8 |
HttpComponent | icemix.common.AsyncBaseLifeCycle 509 |
Transaction is still active after exchange processing. Trying to rollback
transaction.
2010-04-19 22:14:37,078| 22:14:37,078 | ERROR | pool-6-thread-2 |
JcaConsumerProcessor | mix.jms.jca.JcaConsumerProcessor 117 |
Error while handling jms message
javax.jbi.messaging.MessagingException:
javax.transaction.InvalidTransactionException: Specified transaction is
already associated with another thread
at
org.apache.servicemix.common.EndpointDeliveryChannel.resumeTx(EndpointDeliveryChannel.java:137)
at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:118)
at
org.apache.servicemix.jms.jca.JcaConsumerProcessor.onMessage(JcaConsumerProcessor.java:110)
at org.jencks.XAEndpoint.onMessage(XAEndpoint.java:129)
at
org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:123)
at
org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:64)
at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:735)
at
org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:169)
at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:290)
at
org.apache.geronimo.connector.work.pool.NamedRunnable.run(NamedRunnable.java:32)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.transaction.InvalidTransactionException: Specified
transaction is already associated with another thread
at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.associate(TransactionManagerImpl.java:114)
at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.resume(TransactionManagerImpl.java:183)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:64)
at
org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:78)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy23.resume(Unknown Source)
at
org.apache.servicemix.common.EndpointDeliveryChannel.resumeTx(EndpointDeliveryChannel.java:135)
... 12 more
gnanda wrote:
>
> Thanks everyone. I will open up a separate thread to discuss this
>
> iocanel wrote:
>>
>>
>> gnanda wrote:
>>>
>>> Could I use bean class to call http endpoint without using servicemix
>>> client ??
>>>
>> Yes, using the delivery channel, combined with an eip endpoint
>> (pipeline,routingslip are most suitable) that will help you send the OUT
>> of the Exchange to the proper endpoint.
>>
>>
>>
>> gnanda wrote:
>>>
>>> If I make my bean to handle inOut exchange and call
>>> channel.send(outexchange), would that call http end point ?
>>>
>>
>> The pipeline or the routingslip. Here are simplified examples:
>>
>> <-! Using the Pipeline -->
>> <!-- Jms Consumer Sends InOnly to Pipeline. Pipeline sends a copy of
>> InOnly as InOut to bean. Bean produces sets Out Message on the Exchange
>> and sends to Delivery Channel. Pipeline sends the Out as InOnly to http
>> provider -->
>> <eip:pipeline service="sns:pipeline" endpoint="eipEndpoint">
>> <eip:transformer>
>> <eip:exchange-target service="sns:bean" />
>> </eip:transformer>
>> <eip:target>
>> <eip:exchange-target service="sns:http-provider" />
>> </eip:target>
>> </eip:pipeline>
>>
>>
>> Finally you mentioned that you want to decide dynamically where to send
>> the message. This can be done with various ways from using camel
>> recipient lists to implementing some custom logic inside the http
>> provider marshaler. You are free to choose.
>>
>> Now, if the transaction issue you had, has been solved, it might be a
>> good idea to start a new thread about the bean endpoint and the dynamic
>> routing, to keep this clean.
>>
>>
>>
>
>
--
View this message in context:
http://old.nabble.com/SMX4-handling-transaction-tp28199896p28287897.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.