You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by gnanda <gi...@phaseforward.com> on 2010/04/10 06:26:33 UTC

SMX4 handling transaction

Hi,
I am a newbie in servicemix.
I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a service
assembly with 3 SUs. The flow is as below
JMS consumer ->servicemix Bean class-> http provider (accessing external
webservice).  I like to understand how would I impose transactional
capability the the above message flow

 For example: if I receive any error (or fault) while calling the external
service from http provider component then I should be able to rollback  or
commit the message to the queue based one the error code.

Any insight will be very helpful. Thank you in advance.


Here is my xbean definition of jms consumer 

<jms:consumer service="test:MyConsumerService" endpoint="jms"
		targetService="test:MyBeanConsumerService" targetEndpoint="beanendpoint"
		destinationName="spq2" connectionFactory="#connectionFactory"
		concurrentConsumers="4" cacheLevel="3" />

	<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL" value="tcp://localhost:61616" />
		<!--
			not working <property name="redeliveryPolicy" ref="redeliveryPolicy"
			/>
		-->
	</bean>
	<bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
		<property name="maximumRedeliveries" value="8" />
	</bean>
Here is my xbean definition of the bean class
<bean:endpoint service="test:MyBeanConsumerService" endpoint="beanendpoint"
bean="#myBean"/>

  <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>

</beans>

Here is my xbean definition of the http provider

 <http:endpoint service="test:TemperatureConverterService1"
                 endpoint="TemperatureConverterServiceSoap12Binding"
                 role="provider" 
                
locationURI="http://localhost/axis2/services/TemperatureConverterService"
                
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 />             
<!--   
wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl"
-->
</beans>
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
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.InOnlyImpl@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.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
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-tp28199896p28244982.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You can use Camel too to implement EIP. Most of the time, the DSL is 
simpler.

Regards
JB

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.
> 
> 
> 
> -----
> Ioannis Canellos

Re: SMX4 handling transaction

Posted by iocanel <ca...@upstreamsystems.com>.

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.



-----
Ioannis Canellos
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28241763.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
Thank you for all the help. I really appriciate it.


I looked into the pipeline before, I think I cannot use dynamic http
endpoint using pipeleine. In my scenario I parse the message header  in the 
bean class and then set the target uri of the http provider endpoint.
Depending on this URI, http end point calls required external web service as
follows
 outexchange.getInMessage().setProperty( 
		                      JbiConstants.HTTP_DESTINATION_URI, 
		                      uri); 

Could I use bean class to call http endpoint without using servicemix 
client ??
If I make my bean to handle inOut exchange and call
channel.send(outexchange), would that call http end point ?



iocanel wrote:
> 
> 
> gnanda wrote:
>> 
>>  I am sure I am doing something fundamentally wrong.  Please help
>> 
> 
> What I see fundamentally wrong is the fact that you are using the service
> mix client inside you bean endpoint. Bean Endpoints can be injected with
> the Delivery Chanel in order to send exchanges to the bus.
> 
> Let's assume that your bean accepts an exchange performs some processing
> on the exchange and you want to send that exchange to the http provider.
> Then you should make your bean to handle InOut Exchanges and
> alter your flow like this:
> 
> Jms Consumer -> Pipeline Endpoint (Transformer: Bean Endpoint, Target:
> Http Provider).
> 
> Have a look at the "Message Processing Bean" in 
> http://servicemix.apache.org/servicemix-bean.html ServiceMix Bean Examples 
> and at the pipeline in  http://servicemix.apache.org/servicemix-eip.html
> ServiceMix Eip Examples .
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28241613.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by iocanel <ca...@upstreamsystems.com>.

gnanda wrote:
> 
>  I am sure I am doing something fundamentally wrong.  Please help
> 

What I see fundamentally wrong is the fact that you are using the service
mix client inside you bean endpoint. Bean Endpoints can be injected with the
Delivery Chanel in order to send exchanges to the bus.

Let's assume that your bean accepts an exchange performs some processing on
the exchange and you want to send that exchange to the http provider. Then
you should make your bean to handle InOut Exchanges and
alter your flow like this:

Jms Consumer -> Pipeline Endpoint (Transformer: Bean Endpoint, Target: Http
Provider).

Have a look at the "Message Processing Bean" in 
http://servicemix.apache.org/servicemix-bean.html ServiceMix Bean Examples 
and at the pipeline in  http://servicemix.apache.org/servicemix-eip.html
ServiceMix Eip Examples .





-----
Ioannis Canellos
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28240004.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.

Hi all,
I have my flow as jms consumer-> bean class-> http provider ( calling
external service) 
I have my jms consumer defined as below as per suggestion provided. It
worked great with jms->bean pojo class (NO sendsync call to http provider).


When I added http provider component, it is just hanging in the call to
sendSYnc() method. I guess this operation is not being part of the
transaction created from jms endpoint.

 I am sure I am doing something fundamentally wrong.  Please help


  <!-- JMS Consumer -->

      <jms:endpoint id="jmsConsumer" service="test:MyConsumerService"

            endpoint="jmsEndpoint"
targetService="test:MyBeanConsumerService"

             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="spq2"

                        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>

  

</beans>

 



Here is the code snippet that I  am using to call http provider from smx
bean ( I am using sendSync() method) 


client = new ServiceMixClientFacade(context); 
    QName service = new QName("http://test","TemperatureConverterService1"); 
    NormalizedMessage message = exchange.getMessage("in"); 
    Source content = message.getContent(); 
    String body = (new SourceTransformer()).toString(content); 
    log.info("SimpleConsumer:input message body is:"+body); 
    EndpointResolver resolver = client.createResolverForService(service); 
    boolean transactional =
exchange.getProperty("javax.jbi.transaction.jta") != null; 
    log.info("given xchange is transactional:"+transactional); 
    /* the below way of transaction management not working 
    throws exception as below 
    Caused by: javax.transaction.InvalidTransactionException: 
    Specified transaction is already associated with another thread 
    */ 
    // TransactionManager tm = (TransactionManager)
context.getTransactionManager(); 
    // tm.begin(); 
    InOut outexchange = client.createInOutExchange(resolver); 
    
    
    Iterator<String> iterator = exchange.getPropertyNames().iterator(); 
    while (iterator.hasNext()) { 

    String propName = iterator.next(); 
    log.info("RECV:EXCHNG:inside
iterator,propName:"+propName+":"+exchange.getProperty(propName)); 
    log.info("SEND:EXCHNG:inside
iterator,propName:"+propName+":"+outexchange.getProperty(propName)); 
    outexchange.setProperty(propName, exchange.getProperty(propName)); 
    } 
    NormalizedMessage outmessage = outexchange.getInMessage(); 
    outmessage.setContent(new StringSource(body)); 
    String uri = getURIFromMessage(body); 
    log.info("uri is:"+uri); 
    boolean useDynamicUri = true; 
     if (useDynamicUri) { 
     outexchange.getInMessage().setProperty( 
                                      JbiConstants.HTTP_DESTINATION_URI, 
                                      uri); 
         /* outexchange.getInMessage().setProperty( 
                         JbiConstants.HTTP_DESTINATION_URI, 
                         "http://localhost/axis2/services/EchoService"); */ 
               } 
    boolean success = false; 
    boolean good = client.sendSync(outexchange); 
    log.info("SimpleConsumer:invocation is done");
    //Object responseContent = client.request(resolver, null, null, body); 
    //log.info("SimpleConsumer:response is"+responseContent); 
    log.info("SimpleConsumer:response is"+good); 
    log.info("SimpleConsumer:response is"+outexchange.getOutMessage()); 
    log.info("SimpleConsumer:error is"+outexchange.getError()); 
    Fault fault = outexchange.getFault(); 
    String faultbody=null; 
    if(fault != null){ 
    Source faultContent = fault.getContent(); 
    faultbody = (new SourceTransformer()).toString(faultContent); 
    log.info("SimpleConsumer:fault is"+faultbody); 
    } 
    if(outexchange.getOutMessage() != null){ 
    NormalizedMessage responsemessage = outexchange.getOutMessage(); 
    String responsecontent = (new
SourceTransformer()).toString(responsemessage.getContent()); 
    log.info("SimpleConsumer:response body is:"+responsecontent); 
      //log.info("response object is:"+responseContent); 
    success=true; 
    } 
    
    if(success){ 
    
    exchange.setStatus(ExchangeStatus.DONE); 
    channel.send(exchange); 
    //tm.commit(); 
    log.info("transaction committed"); 
    //outexchange.setStatus(ExchangeStatus.DONE); 
    } 
    else{ 
    //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); 
    //tm.rollback(); 
    log.info("transaction rollbacked"); 
    
    //exchange.setStatus(ExchangeStatus.ERROR); 
    
    
    } 



Freeman Fang wrote:
> 
> Hi,
> 
> Could you use the latest apache smx 4.2 snapshot (4.2 will be released  
> soon)?
> 
> Or use the FUSE ESB 4.2[1]
> 
> [1]http://repo.open.iona.com/maven2/org/apache/servicemix/apache-servicemix/4.2.0-fuse-01-00/
> 
> Freeman
> On 2010-4-13, at 上午10:10, gnanda wrote:
> 
>>
>>
>> Hi,
>>
>> Thank you for your quick response.
>>
>> As per your suggestion  I added below lines to my jms consumer  
>> xbean.xml
>> file and I am getting an exception now.  Here is my xbean.xml file
>>
>> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>>      xmlns:test="http://test" xmlns:amq="http://activemq.org/config/1.0 
>> "
>>      xmlns="http://www.springframework.org/schema/beans"
>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>
>>      xsi:schemaLocation="http://servicemix.apache.org/jms/1.0
>> http://servicemix.apache.org/schema/servicemix-jms-3.2.3.xsd
>>       http://activemq.org/config/1.0
>> http://activemq.apache.org/schema/core/activemq-core-4.1.1.xsd
>>       http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>
>>
>>
>>      <jms:consumer service="test:MyConsumerService" endpoint="jms"
>>            targetService="test:MyBeanConsumerService"
>> targetEndpoint="beanendpoint"
>>            destinationName="spq2"  
>> connectionFactory="#connectionFactory"
>>            concurrentConsumers="4" cacheLevel="3"  
>> marshaler="#marshaler"
>>            transacted="jms" />
>>
>>      <!--
>>            END SNIPPET: consumer <jms:endpoint
>> service="test:MyConsumerService"
>>            endpoint="jms+soap"
>> targetInterfaceName="test:MyConsumerInterface"
>>            role="consumer" destinationStyle="queue"
>>            jmsProviderDestinationName="queue/A/Soap" soap="true"
>>            defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>            connectionFactory="#connectionFactory" />
>>      -->
>>      <bean id="connectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>            <property name="brokerURL" value="tcp://localhost:61616" />
>>            <!--
>>                  not working <property name="redeliveryPolicy"
>> ref="redeliveryPolicy"
>>                  />
>>            -->
>>      </bean>
>>      <bean id="redeliveryPolicy"
>> class="org.apache.activemq.RedeliveryPolicy">
>>            <property name="maximumRedeliveries" value="8" />
>>      </bean>
>>
>> <bean id="marshaler"
>>
>> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>>            <property name="mep"
>> value="http://www.w3.org/2004/08/wsdl/in-out
>> " />
>>            <property name="rollbackOnError" value="true" />
>>      </bean>
>>
>>
>>
>> </beans>
>>
>>
>> Exception below:
>> Do I need to start a transaction explicitly somewhere? If yes, how  
>> would I
>> start a transaction?
>>
>> 2010-04-12 21:58:49,342| 21:58:49,342 | WARN  | tenerContainer-7 |
>> DefaultMessageListenerContainer  | AbstractMessageListenerContainer   
>> 646 |
>> Execution of JMS message listener failed
>> javax.jms.JMSException: Error sending JBI exchange
>>                at
>> org 
>> .apache 
>> .servicemix 
>> .jms 
>> .endpoints 
>> .AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
>>                at
>> org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint 
>> $1.onMessage(JmsConsumerEndpoint.java:505)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .doInvokeListener(AbstractMessageListenerContainer.java:518)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .invokeListener(AbstractMessageListenerContainer.java:479)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .doExecuteListener(AbstractMessageListenerContainer.java:451)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractPollingMessageListenerContainer 
>> .doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractPollingMessageListenerContainer 
>> .receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker 
>> .invokeListener(DefaultMessageListenerContainer.java:982)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker 
>> .executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java: 
>> 876)
>>                at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.Exception: ERROR:Fault occurred<?xml  
>> version="1.0"
>> encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/ 
>> envelope/"><soapenv:Body><soapenv:Fault
>> xmlns:axis2ns31="http://schemas.xmlsoap.org/soap/ 
>> envelope/"><faultcode>axis2ns31:Client</faultcode><faultstring>The
>> endpoint reference (EPR) for the Operation not found is
>> http://localhost/axis2/services/EchoService and the WSA Action =
>> null</faultstring><detail/></soapenv:Fault></soapenv:Body></ 
>> soapenv:Envelope>
>>                at
>> org.simpleBeanconsumer.MyBean.onMessageExchange(MyBean.java:147)
>>                at
>> org 
>> .apache 
>> .servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java: 
>> 230)
>>                at
>> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:217)
>>                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)
>>                ... 1 more
>> 2010-04-12 21:58:49,342| 21:58:49,342 | ERROR | //127.0.0.1:4933 |  
>> Service
>> | ivemq.broker.TransportConnection  290 | Async error occurred:
>> javax.jms.JMSException: Transaction
>> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
>> javax.jms.JMSException: Transaction
>> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransactionBroker.getTransaction(TransactionBroker.java:270)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransactionBroker.acknowledge(TransactionBroker.java:190)
>>                at
>> org 
>> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>>                at
>> org 
>> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.MutableBrokerFilter.acknowledge(MutableBrokerFilter.java:85)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker 
>> .TransportConnection.processMessageAck(TransportConnection.java:456)
>>                at
>> org.apache.activemq.command.MessageAck.visit(MessageAck.java:205)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransportConnection.service(TransportConnection.java:305)
>>                at
>> org.apache.activemq.broker.TransportConnection 
>> $1.onCommand(TransportConnection.java:179)
>>                at
>> org 
>> .apache 
>> .activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java: 
>> 143)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
>>                at
>> org 
>> .apache 
>> .activemq.transport.TransportSupport.doConsume(TransportSupport.java: 
>> 84)
>>                at
>> org 
>> .apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java: 
>> 203)
>>                at
>> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java: 
>> 185)
>>                at java.lang.Thread.run(Thread.java:619)
>>
>> Thanks & Regards
>> Gita
>>
>>
>>
>>
>>
>>
>> Freeman Fang wrote:
>>>
>>> Hi,
>>>
>>> You can simply add
>>> 			marshaler="#marshaler"
>>>                       transacted="jms"
>>> attribute for your jms consumer to enable transaction.
>>> here the marshaler is,
>>>    <bean id="marshaler"
>>> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>>>        <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out
>>> " />
>>>        <property name="rollbackOnError" value="true"/>
>>>     </bean>
>>>  notice you must set <property name="rollbackOnError" value="true"/>
>>>
>>> then when a Error message back to your jms consumer, the jms comsumer
>>> will do rollback.
>>>
>>>
>>> Freeman
>>>
>>>
>>> On 2010-4-10, at 下午12:26, gnanda wrote:
>>>
>>>>
>>>> Hi,
>>>> I am a newbie in servicemix.
>>>> I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a
>>>> service
>>>> assembly with 3 SUs. The flow is as below
>>>> JMS consumer ->servicemix Bean class-> http provider (accessing
>>>> external
>>>> webservice).  I like to understand how would I impose transactional
>>>> capability the the above message flow
>>>>
>>>> For example: if I receive any error (or fault) while calling the
>>>> external
>>>> service from http provider component then I should be able to
>>>> rollback  or
>>>> commit the message to the queue based one the error code.
>>>>
>>>> Any insight will be very helpful. Thank you in advance.
>>>>
>>>>
>>>> Here is my xbean definition of jms consumer
>>>>
>>>> <jms:consumer service="test:MyConsumerService" endpoint="jms"
>>>> 		targetService="test:MyBeanConsumerService"
>>>> targetEndpoint="beanendpoint"
>>>> 		destinationName="spq2" connectionFactory="#connectionFactory"
>>>> 		concurrentConsumers="4" cacheLevel="3" />
>>>>
>>>> 	<bean id="connectionFactory"
>>>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>>> 		<property name="brokerURL" value="tcp://localhost:61616" />
>>>> 		<!--
>>>> 			not working <property name="redeliveryPolicy"
>>>> ref="redeliveryPolicy"
>>>> 			/>
>>>> 		-->
>>>> 	</bean>
>>>> 	<bean id="redeliveryPolicy"
>>>> class="org.apache.activemq.RedeliveryPolicy">
>>>> 		<property name="maximumRedeliveries" value="8" />
>>>> 	</bean>
>>>> Here is my xbean definition of the bean class
>>>> <bean:endpoint service="test:MyBeanConsumerService"
>>>> endpoint="beanendpoint"
>>>> bean="#myBean"/>
>>>>
>>>> <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>
>>>>
>>>> </beans>
>>>>
>>>> Here is my xbean definition of the http provider
>>>>
>>>> <http:endpoint service="test:TemperatureConverterService1"
>>>>                endpoint="TemperatureConverterServiceSoap12Binding"
>>>>                role="provider"
>>>>
>>>> locationURI="http://localhost/axis2/services/TemperatureConverterService
>>>> "
>>>>
>>>>                defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                />
>>>> <!--
>>>> wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl
>>>> "
>>>> -->
>>>> </beans>
>>>> -- 
>>>> View this message in context:
>>>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>> -- 
>>> Freeman Fang
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28219212.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
> 
> 
> -- 
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28237095.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.

Does that mean smx 4.0 has a bug and fixed in 4.2.? 
I will give it a  try with smx 4.2. 

Freeman Fang wrote:
> 
> Hi,
> 
> Could you use the latest apache smx 4.2 snapshot (4.2 will be released  
> soon)?
> 
> Or use the FUSE ESB 4.2[1]
> 
> [1]http://repo.open.iona.com/maven2/org/apache/servicemix/apache-servicemix/4.2.0-fuse-01-00/
> 
> Freeman
> On 2010-4-13, at 上午10:10, gnanda wrote:
> 
>>
>>
>> Hi,
>>
>> Thank you for your quick response.
>>
>> As per your suggestion  I added below lines to my jms consumer  
>> xbean.xml
>> file and I am getting an exception now.  Here is my xbean.xml file
>>
>> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>>      xmlns:test="http://test" xmlns:amq="http://activemq.org/config/1.0 
>> "
>>      xmlns="http://www.springframework.org/schema/beans"
>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>
>>      xsi:schemaLocation="http://servicemix.apache.org/jms/1.0
>> http://servicemix.apache.org/schema/servicemix-jms-3.2.3.xsd
>>       http://activemq.org/config/1.0
>> http://activemq.apache.org/schema/core/activemq-core-4.1.1.xsd
>>       http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>
>>
>>
>>      <jms:consumer service="test:MyConsumerService" endpoint="jms"
>>            targetService="test:MyBeanConsumerService"
>> targetEndpoint="beanendpoint"
>>            destinationName="spq2"  
>> connectionFactory="#connectionFactory"
>>            concurrentConsumers="4" cacheLevel="3"  
>> marshaler="#marshaler"
>>            transacted="jms" />
>>
>>      <!--
>>            END SNIPPET: consumer <jms:endpoint
>> service="test:MyConsumerService"
>>            endpoint="jms+soap"
>> targetInterfaceName="test:MyConsumerInterface"
>>            role="consumer" destinationStyle="queue"
>>            jmsProviderDestinationName="queue/A/Soap" soap="true"
>>            defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>            connectionFactory="#connectionFactory" />
>>      -->
>>      <bean id="connectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>            <property name="brokerURL" value="tcp://localhost:61616" />
>>            <!--
>>                  not working <property name="redeliveryPolicy"
>> ref="redeliveryPolicy"
>>                  />
>>            -->
>>      </bean>
>>      <bean id="redeliveryPolicy"
>> class="org.apache.activemq.RedeliveryPolicy">
>>            <property name="maximumRedeliveries" value="8" />
>>      </bean>
>>
>> <bean id="marshaler"
>>
>> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>>            <property name="mep"
>> value="http://www.w3.org/2004/08/wsdl/in-out
>> " />
>>            <property name="rollbackOnError" value="true" />
>>      </bean>
>>
>>
>>
>> </beans>
>>
>>
>> Exception below:
>> Do I need to start a transaction explicitly somewhere? If yes, how  
>> would I
>> start a transaction?
>>
>> 2010-04-12 21:58:49,342| 21:58:49,342 | WARN  | tenerContainer-7 |
>> DefaultMessageListenerContainer  | AbstractMessageListenerContainer   
>> 646 |
>> Execution of JMS message listener failed
>> javax.jms.JMSException: Error sending JBI exchange
>>                at
>> org 
>> .apache 
>> .servicemix 
>> .jms 
>> .endpoints 
>> .AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
>>                at
>> org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint 
>> $1.onMessage(JmsConsumerEndpoint.java:505)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .doInvokeListener(AbstractMessageListenerContainer.java:518)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .invokeListener(AbstractMessageListenerContainer.java:479)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractMessageListenerContainer 
>> .doExecuteListener(AbstractMessageListenerContainer.java:451)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractPollingMessageListenerContainer 
>> .doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>>                at
>> org 
>> .springframework 
>> .jms 
>> .listener 
>> .AbstractPollingMessageListenerContainer 
>> .receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker 
>> .invokeListener(DefaultMessageListenerContainer.java:982)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker 
>> .executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>>                at
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $ 
>> AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java: 
>> 876)
>>                at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.Exception: ERROR:Fault occurred<?xml  
>> version="1.0"
>> encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/ 
>> envelope/"><soapenv:Body><soapenv:Fault
>> xmlns:axis2ns31="http://schemas.xmlsoap.org/soap/ 
>> envelope/"><faultcode>axis2ns31:Client</faultcode><faultstring>The
>> endpoint reference (EPR) for the Operation not found is
>> http://localhost/axis2/services/EchoService and the WSA Action =
>> null</faultstring><detail/></soapenv:Fault></soapenv:Body></ 
>> soapenv:Envelope>
>>                at
>> org.simpleBeanconsumer.MyBean.onMessageExchange(MyBean.java:147)
>>                at
>> org 
>> .apache 
>> .servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java: 
>> 230)
>>                at
>> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:217)
>>                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)
>>                ... 1 more
>> 2010-04-12 21:58:49,342| 21:58:49,342 | ERROR | //127.0.0.1:4933 |  
>> Service
>> | ivemq.broker.TransportConnection  290 | Async error occurred:
>> javax.jms.JMSException: Transaction
>> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
>> javax.jms.JMSException: Transaction
>> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransactionBroker.getTransaction(TransactionBroker.java:270)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransactionBroker.acknowledge(TransactionBroker.java:190)
>>                at
>> org 
>> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>>                at
>> org 
>> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.MutableBrokerFilter.acknowledge(MutableBrokerFilter.java:85)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker 
>> .TransportConnection.processMessageAck(TransportConnection.java:456)
>>                at
>> org.apache.activemq.command.MessageAck.visit(MessageAck.java:205)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .broker.TransportConnection.service(TransportConnection.java:305)
>>                at
>> org.apache.activemq.broker.TransportConnection 
>> $1.onCommand(TransportConnection.java:179)
>>                at
>> org 
>> .apache 
>> .activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java: 
>> 143)
>>                at
>> org 
>> .apache 
>> .activemq 
>> .transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
>>                at
>> org 
>> .apache 
>> .activemq.transport.TransportSupport.doConsume(TransportSupport.java: 
>> 84)
>>                at
>> org 
>> .apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java: 
>> 203)
>>                at
>> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java: 
>> 185)
>>                at java.lang.Thread.run(Thread.java:619)
>>
>> Thanks & Regards
>> Gita
>>
>>
>>
>>
>>
>>
>> Freeman Fang wrote:
>>>
>>> Hi,
>>>
>>> You can simply add
>>> 			marshaler="#marshaler"
>>>                       transacted="jms"
>>> attribute for your jms consumer to enable transaction.
>>> here the marshaler is,
>>>    <bean id="marshaler"
>>> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>>>        <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out
>>> " />
>>>        <property name="rollbackOnError" value="true"/>
>>>     </bean>
>>>  notice you must set <property name="rollbackOnError" value="true"/>
>>>
>>> then when a Error message back to your jms consumer, the jms comsumer
>>> will do rollback.
>>>
>>>
>>> Freeman
>>>
>>>
>>> On 2010-4-10, at 下午12:26, gnanda wrote:
>>>
>>>>
>>>> Hi,
>>>> I am a newbie in servicemix.
>>>> I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a
>>>> service
>>>> assembly with 3 SUs. The flow is as below
>>>> JMS consumer ->servicemix Bean class-> http provider (accessing
>>>> external
>>>> webservice).  I like to understand how would I impose transactional
>>>> capability the the above message flow
>>>>
>>>> For example: if I receive any error (or fault) while calling the
>>>> external
>>>> service from http provider component then I should be able to
>>>> rollback  or
>>>> commit the message to the queue based one the error code.
>>>>
>>>> Any insight will be very helpful. Thank you in advance.
>>>>
>>>>
>>>> Here is my xbean definition of jms consumer
>>>>
>>>> <jms:consumer service="test:MyConsumerService" endpoint="jms"
>>>> 		targetService="test:MyBeanConsumerService"
>>>> targetEndpoint="beanendpoint"
>>>> 		destinationName="spq2" connectionFactory="#connectionFactory"
>>>> 		concurrentConsumers="4" cacheLevel="3" />
>>>>
>>>> 	<bean id="connectionFactory"
>>>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>>> 		<property name="brokerURL" value="tcp://localhost:61616" />
>>>> 		<!--
>>>> 			not working <property name="redeliveryPolicy"
>>>> ref="redeliveryPolicy"
>>>> 			/>
>>>> 		-->
>>>> 	</bean>
>>>> 	<bean id="redeliveryPolicy"
>>>> class="org.apache.activemq.RedeliveryPolicy">
>>>> 		<property name="maximumRedeliveries" value="8" />
>>>> 	</bean>
>>>> Here is my xbean definition of the bean class
>>>> <bean:endpoint service="test:MyBeanConsumerService"
>>>> endpoint="beanendpoint"
>>>> bean="#myBean"/>
>>>>
>>>> <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>
>>>>
>>>> </beans>
>>>>
>>>> Here is my xbean definition of the http provider
>>>>
>>>> <http:endpoint service="test:TemperatureConverterService1"
>>>>                endpoint="TemperatureConverterServiceSoap12Binding"
>>>>                role="provider"
>>>>
>>>> locationURI="http://localhost/axis2/services/TemperatureConverterService
>>>> "
>>>>
>>>>                defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                />
>>>> <!--
>>>> wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl
>>>> "
>>>> -->
>>>> </beans>
>>>> -- 
>>>> View this message in context:
>>>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>> -- 
>>> Freeman Fang
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28219212.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
> 
> 
> -- 
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28229194.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Could you use the latest apache smx 4.2 snapshot (4.2 will be released  
soon)?

Or use the FUSE ESB 4.2[1]

[1]http://repo.open.iona.com/maven2/org/apache/servicemix/apache-servicemix/4.2.0-fuse-01-00/

Freeman
On 2010-4-13, at 上午10:10, gnanda wrote:

>
>
> Hi,
>
> Thank you for your quick response.
>
> As per your suggestion  I added below lines to my jms consumer  
> xbean.xml
> file and I am getting an exception now.  Here is my xbean.xml file
>
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>      xmlns:test="http://test" xmlns:amq="http://activemq.org/config/1.0 
> "
>      xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>
>      xsi:schemaLocation="http://servicemix.apache.org/jms/1.0
> http://servicemix.apache.org/schema/servicemix-jms-3.2.3.xsd
>       http://activemq.org/config/1.0
> http://activemq.apache.org/schema/core/activemq-core-4.1.1.xsd
>       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>
>
>      <jms:consumer service="test:MyConsumerService" endpoint="jms"
>            targetService="test:MyBeanConsumerService"
> targetEndpoint="beanendpoint"
>            destinationName="spq2"  
> connectionFactory="#connectionFactory"
>            concurrentConsumers="4" cacheLevel="3"  
> marshaler="#marshaler"
>            transacted="jms" />
>
>      <!--
>            END SNIPPET: consumer <jms:endpoint
> service="test:MyConsumerService"
>            endpoint="jms+soap"
> targetInterfaceName="test:MyConsumerInterface"
>            role="consumer" destinationStyle="queue"
>            jmsProviderDestinationName="queue/A/Soap" soap="true"
>            defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>            connectionFactory="#connectionFactory" />
>      -->
>      <bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>            <property name="brokerURL" value="tcp://localhost:61616" />
>            <!--
>                  not working <property name="redeliveryPolicy"
> ref="redeliveryPolicy"
>                  />
>            -->
>      </bean>
>      <bean id="redeliveryPolicy"
> class="org.apache.activemq.RedeliveryPolicy">
>            <property name="maximumRedeliveries" value="8" />
>      </bean>
>
> <bean id="marshaler"
>
> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>            <property name="mep"
> value="http://www.w3.org/2004/08/wsdl/in-out
> " />
>            <property name="rollbackOnError" value="true" />
>      </bean>
>
>
>
> </beans>
>
>
> Exception below:
> Do I need to start a transaction explicitly somewhere? If yes, how  
> would I
> start a transaction?
>
> 2010-04-12 21:58:49,342| 21:58:49,342 | WARN  | tenerContainer-7 |
> DefaultMessageListenerContainer  | AbstractMessageListenerContainer   
> 646 |
> Execution of JMS message listener failed
> javax.jms.JMSException: Error sending JBI exchange
>                at
> org 
> .apache 
> .servicemix 
> .jms 
> .endpoints 
> .AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
>                at
> org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint 
> $1.onMessage(JmsConsumerEndpoint.java:505)
>                at
> org 
> .springframework 
> .jms 
> .listener 
> .AbstractMessageListenerContainer 
> .doInvokeListener(AbstractMessageListenerContainer.java:518)
>                at
> org 
> .springframework 
> .jms 
> .listener 
> .AbstractMessageListenerContainer 
> .invokeListener(AbstractMessageListenerContainer.java:479)
>                at
> org 
> .springframework 
> .jms 
> .listener 
> .AbstractMessageListenerContainer 
> .doExecuteListener(AbstractMessageListenerContainer.java:451)
>                at
> org 
> .springframework 
> .jms 
> .listener 
> .AbstractPollingMessageListenerContainer 
> .doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>                at
> org 
> .springframework 
> .jms 
> .listener 
> .AbstractPollingMessageListenerContainer 
> .receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
>                at
> org.springframework.jms.listener.DefaultMessageListenerContainer 
> $ 
> AsyncMessageListenerInvoker 
> .invokeListener(DefaultMessageListenerContainer.java:982)
>                at
> org.springframework.jms.listener.DefaultMessageListenerContainer 
> $ 
> AsyncMessageListenerInvoker 
> .executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>                at
> org.springframework.jms.listener.DefaultMessageListenerContainer 
> $ 
> AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java: 
> 876)
>                at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.Exception: ERROR:Fault occurred<?xml  
> version="1.0"
> encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/ 
> envelope/"><soapenv:Body><soapenv:Fault
> xmlns:axis2ns31="http://schemas.xmlsoap.org/soap/ 
> envelope/"><faultcode>axis2ns31:Client</faultcode><faultstring>The
> endpoint reference (EPR) for the Operation not found is
> http://localhost/axis2/services/EchoService and the WSA Action =
> null</faultstring><detail/></soapenv:Fault></soapenv:Body></ 
> soapenv:Envelope>
>                at
> org.simpleBeanconsumer.MyBean.onMessageExchange(MyBean.java:147)
>                at
> org 
> .apache 
> .servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java: 
> 230)
>                at
> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:217)
>                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)
>                ... 1 more
> 2010-04-12 21:58:49,342| 21:58:49,342 | ERROR | //127.0.0.1:4933 |  
> Service
> | ivemq.broker.TransportConnection  290 | Async error occurred:
> javax.jms.JMSException: Transaction
> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
> javax.jms.JMSException: Transaction
> 'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
>                at
> org 
> .apache 
> .activemq 
> .broker.TransactionBroker.getTransaction(TransactionBroker.java:270)
>                at
> org 
> .apache 
> .activemq 
> .broker.TransactionBroker.acknowledge(TransactionBroker.java:190)
>                at
> org 
> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>                at
> org 
> .apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
>                at
> org 
> .apache 
> .activemq 
> .broker.MutableBrokerFilter.acknowledge(MutableBrokerFilter.java:85)
>                at
> org 
> .apache 
> .activemq 
> .broker 
> .TransportConnection.processMessageAck(TransportConnection.java:456)
>                at
> org.apache.activemq.command.MessageAck.visit(MessageAck.java:205)
>                at
> org 
> .apache 
> .activemq 
> .broker.TransportConnection.service(TransportConnection.java:305)
>                at
> org.apache.activemq.broker.TransportConnection 
> $1.onCommand(TransportConnection.java:179)
>                at
> org 
> .apache 
> .activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
>                at
> org 
> .apache 
> .activemq 
> .transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java: 
> 143)
>                at
> org 
> .apache 
> .activemq 
> .transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
>                at
> org 
> .apache 
> .activemq.transport.TransportSupport.doConsume(TransportSupport.java: 
> 84)
>                at
> org 
> .apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java: 
> 203)
>                at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java: 
> 185)
>                at java.lang.Thread.run(Thread.java:619)
>
> Thanks & Regards
> Gita
>
>
>
>
>
>
> Freeman Fang wrote:
>>
>> Hi,
>>
>> You can simply add
>> 			marshaler="#marshaler"
>>                       transacted="jms"
>> attribute for your jms consumer to enable transaction.
>> here the marshaler is,
>>    <bean id="marshaler"
>> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>>        <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out
>> " />
>>        <property name="rollbackOnError" value="true"/>
>>     </bean>
>>  notice you must set <property name="rollbackOnError" value="true"/>
>>
>> then when a Error message back to your jms consumer, the jms comsumer
>> will do rollback.
>>
>>
>> Freeman
>>
>>
>> On 2010-4-10, at 下午12:26, gnanda wrote:
>>
>>>
>>> Hi,
>>> I am a newbie in servicemix.
>>> I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a
>>> service
>>> assembly with 3 SUs. The flow is as below
>>> JMS consumer ->servicemix Bean class-> http provider (accessing
>>> external
>>> webservice).  I like to understand how would I impose transactional
>>> capability the the above message flow
>>>
>>> For example: if I receive any error (or fault) while calling the
>>> external
>>> service from http provider component then I should be able to
>>> rollback  or
>>> commit the message to the queue based one the error code.
>>>
>>> Any insight will be very helpful. Thank you in advance.
>>>
>>>
>>> Here is my xbean definition of jms consumer
>>>
>>> <jms:consumer service="test:MyConsumerService" endpoint="jms"
>>> 		targetService="test:MyBeanConsumerService"
>>> targetEndpoint="beanendpoint"
>>> 		destinationName="spq2" connectionFactory="#connectionFactory"
>>> 		concurrentConsumers="4" cacheLevel="3" />
>>>
>>> 	<bean id="connectionFactory"
>>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>> 		<property name="brokerURL" value="tcp://localhost:61616" />
>>> 		<!--
>>> 			not working <property name="redeliveryPolicy"
>>> ref="redeliveryPolicy"
>>> 			/>
>>> 		-->
>>> 	</bean>
>>> 	<bean id="redeliveryPolicy"
>>> class="org.apache.activemq.RedeliveryPolicy">
>>> 		<property name="maximumRedeliveries" value="8" />
>>> 	</bean>
>>> Here is my xbean definition of the bean class
>>> <bean:endpoint service="test:MyBeanConsumerService"
>>> endpoint="beanendpoint"
>>> bean="#myBean"/>
>>>
>>> <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>
>>>
>>> </beans>
>>>
>>> Here is my xbean definition of the http provider
>>>
>>> <http:endpoint service="test:TemperatureConverterService1"
>>>                endpoint="TemperatureConverterServiceSoap12Binding"
>>>                role="provider"
>>>
>>> locationURI="http://localhost/axis2/services/TemperatureConverterService
>>> "
>>>
>>>                defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                />
>>> <!--
>>> wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl
>>> "
>>> -->
>>> </beans>
>>> -- 
>>> View this message in context:
>>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>
>>
>> -- 
>> Freeman Fang
>> ------------------------
>> Open Source SOA: http://fusesource.com
>>
>>
>>
>
> -- 
> View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28219212.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
It worked wonderful with my jmslistener calling a simple smx:bean component. 


I have my flow as jms consumer-> bean class-> http provider ( calling
external service)
When I add http provider componenet, it is just hanging. I am sure I am
doing something fundamentally wrong.  Please suggest.


Here is the code snippet that I  am using to call http provider from smx
bean ( I am using sendSync() method)


client = new ServiceMixClientFacade(context);
    			QName service = new
QName("http://test","TemperatureConverterService1");
    			NormalizedMessage message = exchange.getMessage("in");
    			Source content = message.getContent();
    			String body = (new SourceTransformer()).toString(content);
    			log.info("SimpleConsumer:input message body is:"+body);
    			EndpointResolver resolver = client.createResolverForService(service);
    			boolean transactional =
exchange.getProperty("javax.jbi.transaction.jta") != null;
    			log.info("given xchange is transactional:"+transactional);
    			/* the below way of transaction management not working
    			throws exception as below
    			Caused by: javax.transaction.InvalidTransactionException: 
    				Specified transaction is already associated with another thread
    				*/
    			// TransactionManager tm = (TransactionManager)
context.getTransactionManager();
    			// tm.begin();
    			InOut outexchange = client.createInOutExchange(resolver);
    			
    			
    			Iterator<String> iterator = exchange.getPropertyNames().iterator();
    			while (iterator.hasNext()) {

    						String propName = iterator.next();
    						log.info("RECV:EXCHNG:inside
iterator,propName:"+propName+":"+exchange.getProperty(propName));
    						log.info("SEND:EXCHNG:inside
iterator,propName:"+propName+":"+outexchange.getProperty(propName));
    						outexchange.setProperty(propName, exchange.getProperty(propName));
    			}
    			NormalizedMessage outmessage = outexchange.getInMessage();
    			outmessage.setContent(new StringSource(body));
    			String uri = getURIFromMessage(body);
    			log.info("uri is:"+uri);
    			boolean useDynamicUri = true;
    			 if (useDynamicUri) { 
    				  outexchange.getInMessage().setProperty( 
		                      JbiConstants.HTTP_DESTINATION_URI, 
		                      uri); 
    				      /* outexchange.getInMessage().setProperty( 
    				                      JbiConstants.HTTP_DESTINATION_URI, 
    				                     
"http://localhost/axis2/services/EchoService"); */
    				            } 
    			boolean success = false;
    			 boolean good = client.sendSync(outexchange); 
    			log.info("SimpleConsumer:invocation is done");
    			//Object responseContent = client.request(resolver, null, null,
body);
    			//log.info("SimpleConsumer:response is"+responseContent);
    			log.info("SimpleConsumer:response is"+good);
    			log.info("SimpleConsumer:response is"+outexchange.getOutMessage());
    			log.info("SimpleConsumer:error is"+outexchange.getError());
    			Fault fault = outexchange.getFault();
    			String faultbody=null;
    			if(fault != null){
    			Source faultContent = fault.getContent();
    			faultbody = (new SourceTransformer()).toString(faultContent);
    			log.info("SimpleConsumer:fault is"+faultbody);
    			}
    			if(outexchange.getOutMessage() != null){
    			NormalizedMessage responsemessage = outexchange.getOutMessage();
    			String responsecontent = (new
SourceTransformer()).toString(responsemessage.getContent());
    			log.info("SimpleConsumer:response body is:"+responsecontent);
     			//log.info("response object is:"+responseContent);
    			success=true;
    			}
    			
    			if(success){
    				
    				exchange.setStatus(ExchangeStatus.DONE);
    				channel.send(exchange);
    				//tm.commit();
    				log.info("transaction committed");
    				//outexchange.setStatus(ExchangeStatus.DONE);
    			}
    			else{
    				//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);
    				//tm.rollback();
    				log.info("transaction rollbacked");
    				
    				//exchange.setStatus(ExchangeStatus.ERROR);
    				
    				
    			}



iocanel wrote:
> 
> The error you have is beacause BootstrapContextFactoryBean requires a
> reference to the transaction manager:
> 
> <bean id="bootstrapContext"
> class="org.jencks.factory.BootstrapContextFactoryBean">
>                 <property name="threadPoolSize" value="15" />
>                 <property name="transactionManager"
> ref="transactionManager" />
> </bean>
> 
> <bean id="transactionManager"
> class="org.jencks.factory.TransactionManagerFactoryBean"/>
> 
> 
> As I told you in my first post the way that you are going to create the
> bootstrap context depends on your environment setup. In your case
> (servicemix 4) I think that will work.
> 
> 
http://old.nabble.com/file/p28233842/MyBean.java MyBean.java 
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28233842.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by iocanel <ca...@upstreamsystems.com>.
The error you have is beacause BootstrapContextFactoryBean requires a
reference to the transaction manager:

<bean id="bootstrapContext"
class="org.jencks.factory.BootstrapContextFactoryBean">
                <property name="threadPoolSize" value="15" />
                <property name="transactionManager" ref="transactionManager"
/>
</bean>

<bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean"/>


As I told you in my first post the way that you are going to create the
bootstrap context depends on your environment setup. In your case
(servicemix 4) I think that will work.


-----
Ioannis Canellos
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28232012.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
I modified my xbean.xml as per your suggestion. It looks as below

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
	xmlns:test="http://test" xmlns:amq="http://activemq.org/config/1.0"
	xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
	xmlns:amqpool="http://jencks.org/amqpool/2.0" 
	xmlns:amqra="http://activemq.apache.org/schema/ra"

	xsi:schemaLocation="http://servicemix.apache.org/jms/1.0
http://servicemix.apache.org/schema/servicemix-jms-3.2.3.xsd
       http://activemq.org/config/1.0
http://activemq.apache.org/schema/core/activemq-core-4.1.1.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


	<!-- JMS Consumer -->
	<jms:endpoint id="jmsConsumer" service="test:MyConsumerService"
		endpoint="jmsEndpoint" targetService="test:MyBeanConsumerService"
		targetendpoint="beanendpoint" 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="yet.another.queue"
				destinationType="javax.jms.Queue" maximumRedeliveries="5"
				initialRedeliveryDelay="10000" useExponentialBackOff="false" />
		</jms:activationSpec>
	</jms:endpoint>

	<bean id="bootstrapContext"
class="org.jencks.factory.BootstrapContextFactoryBean">
		<property name="threadPoolSize" value="15" />
	</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>




</beans>

At the deployement time I am geeting following error. Do I need to setup
transaction manager? Please suugest.



2010-04-13 11:03:00,442| 11:03:00,442 | ERROR | Timer-1          | Deployer                        
| cemix.jbi.deployer.impl.Deployer  362 | Error handling bundle start event
javax.jbi.JBIException: java.lang.Exception: Error deploying SU
simplejmsConsumer
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.install(ServiceAssemblyInstaller.java:101)
	at
org.apache.servicemix.jbi.deployer.impl.Deployer.onBundleStarted(Deployer.java:354)
	at
org.apache.servicemix.jbi.deployer.impl.Deployer.bundleChanged(Deployer.java:284)
	at
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:771)
	at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:700)
	at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:597)
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3382)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:1517)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:770)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:751)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor.refreshPackagesAndStartOrUpdateBundles(FileMonitor.java:549)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor.onFilesChanged(FileMonitor.java:299)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor$1.filesChanged(FileMonitor.java:151)
	at
org.apache.servicemix.kernel.filemonitor.Scanner.reportBulkChanges(Scanner.java:431)
	at
org.apache.servicemix.kernel.filemonitor.Scanner.reportDifferences(Scanner.java:327)
	at org.apache.servicemix.kernel.filemonitor.Scanner.scan(Scanner.java:261)
	at org.apache.servicemix.kernel.filemonitor.Scanner$1.run(Scanner.java:221)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.Exception: Error deploying SU simplejmsConsumer
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.deploySUs(ServiceAssemblyInstaller.java:210)
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.install(ServiceAssemblyInstaller.java:85)
	... 18 more
Caused by: javax.jbi.management.DeploymentException: <component-task-result
xmlns="http://java.sun.com/xml/ns/jbi/management-message">
	<component-name>servicemix-jms</component-name>
	<component-task-result-details>
		<task-result-details>
			<task-id>deploy</task-id>
			<task-result>FAILED</task-result>
			<message-type>ERROR</message-type>
			<task-status-msg><msg-loc-info><loc-token/><loc-message>Could not deploy
xbean service unit</loc-message></msg-loc-info></task-status-msg>
			<exception-info>
				<nesting-level>1</nesting-level>
				<msg-loc-info>
					<loc-token />
					<loc-message>Error creating bean with name 'jmsConsumer' defined in
file
[C:\phaseforward\workspace\servicemix\apache-servicemix-4.0.0\data\jbi\simpleconsumer-sa\sus\simplejmsConsumer\xbean.xml]:
Cannot resolve reference to bean 'bootstrapContext' while setting bean
property 'bootstrapContext'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'bootstrapContext' defined in file
[C:\phaseforward\workspace\servicemix\apache-servicemix-4.0.0\data\jbi\simpleconsumer-sa\sus\simplejmsConsumer\xbean.xml]:
Invocation of init method failed; nested exception is
org.springframework.beans.FatalBeanException: Geronimo transaction manager
was not set</loc-message>
				
<stack-trace><![CDATA[org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jmsConsumer' defined in file
[C:\phaseforward\workspace\servicemix\apache-servicemix-4.0.0\data\jbi\simpleconsumer-sa\sus\simplejmsConsumer\xbean.xml]:
Cannot resolve reference to bean 'bootstrapContext' while setting bean
property 'bootstrapContext'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'bootstrapContext' defined in file
[C:\phaseforward\workspace\servicemix\apache-servicemix-4.0.0\data\jbi\simpleconsumer-sa\sus\simplejmsConsumer\xbean.xml]:
Invocation of init method failed; nested exception is
org.springframework.beans.FatalBeanException: Geronimo transaction manager
was not set
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
	at
org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:87)
	at
org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
	at
org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
	at
org.apache.servicemix.jbi.deployer.artifacts.ServiceUnitImpl.deploy(ServiceUnitImpl.java:100)
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.deploySUs(ServiceAssemblyInstaller.java:204)
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.install(ServiceAssemblyInstaller.java:85)
	at
org.apache.servicemix.jbi.deployer.impl.Deployer.onBundleStarted(Deployer.java:354)
	at
org.apache.servicemix.jbi.deployer.impl.Deployer.bundleChanged(Deployer.java:284)
	at
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:771)
	at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:700)
	at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:597)
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3382)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:1517)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:770)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:751)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor.refreshPackagesAndStartOrUpdateBundles(FileMonitor.java:549)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor.onFilesChanged(FileMonitor.java:299)
	at
org.apache.servicemix.kernel.filemonitor.FileMonitor$1.filesChanged(FileMonitor.java:151)
	at
org.apache.servicemix.kernel.filemonitor.Scanner.reportBulkChanges(Scanner.java:431)
	at
org.apache.servicemix.kernel.filemonitor.Scanner.reportDifferences(Scanner.java:327)
	at org.apache.servicemix.kernel.filemonitor.Scanner.scan(Scanner.java:261)
	at org.apache.servicemix.kernel.filemonitor.Scanner$1.run(Scanner.java:221)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'bootstrapContext' defined in file
[C:\phaseforward\workspace\servicemix\apache-servicemix-4.0.0\data\jbi\simpleconsumer-sa\sus\simplejmsConsumer\xbean.xml]:
Invocation of init method failed; nested exception is
org.springframework.beans.FatalBeanException: Geronimo transaction manager
was not set
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
	... 39 more
Caused by: org.springframework.beans.FatalBeanException: Geronimo
transaction manager was not set
	at
org.jencks.factory.BootstrapContextFactoryBean.afterPropertiesSet(BootstrapContextFactoryBean.java:75)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 49 more
]]></stack-trace>
				</msg-loc-info>
			</exception-info>
		</task-result-details>
	</component-task-result-details>
</component-task-result>
	at
org.apache.servicemix.common.ManagementSupport.failure(ManagementSupport.java:46)
	at
org.apache.servicemix.common.AbstractDeployer.failure(AbstractDeployer.java:43)
	at
org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:117)
	at
org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
	at
org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
	at
org.apache.servicemix.jbi.deployer.artifacts.ServiceUnitImpl.deploy(ServiceUnitImpl.java:100)
	at
org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.deploySUs(ServiceAssemblyInstaller.java:204)
	... 19 more
2010-04-13 11:03:00,442| 11:03:00,442 | INFO  | Timer-1          |
FileMonitor                      | x.kernel.filemonitor.FileMonitor  550 |
Started: simpleconsumer-sa [428]




iocanel wrote:
> 
> 
> gnanda wrote:
>> 
>> Is this endpoint backed by spring's DefaultMessageListenerContainer?  I
>> would like to use the jms consumer in asynchronous way.  I see you have
>> synchronous="true" setting with jms endpoint.Would it work with
>> synchronous="false" too?
>> 
> 
> Since your consumer is transactional I can't see any added value in having
> it being asynchronous. Eventually you will be constrained by the maximum
> number of sessions or open transactions.
> 
> Back to your question. No I don't think that it is backed by
> DefaultMessageListenerContainer (a good thing IMHO). I haven't tried using
> jms endpoint as transactional and asynchronous.
> 
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28231560.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by iocanel <ca...@upstreamsystems.com>.

gnanda wrote:
> 
> Is this endpoint backed by spring's DefaultMessageListenerContainer?  I
> would like to use the jms consumer in asynchronous way.  I see you have
> synchronous="true" setting with jms endpoint.Would it work with
> synchronous="false" too?
> 

Since your consumer is transactional I can't see any added value in having
it being asynchronous. Eventually you will be constrained by the maximum
number of sessions or open transactions.

Back to your question. No I don't think that it is backed by
DefaultMessageListenerContainer (a good thing IMHO). I haven't tried using
jms endpoint as transactional and asynchronous.

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28231029.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.
Is this endpoint backed by spring's DefaultMessageListenerContainer?  I would
like to use the jms consumer in asynchronous way.  I see you have
synchronous="true" setting with jms endpoint.Would it work with
synchronous="false" too?

 Thank you for helping me out here.



iocanel wrote:
> 
> I had the same issue. A viable work around this issue would be to use the
> old endpoints (which seem more mature to me):
> 
>     <!-- JMS Consumer -->
>     <jms:endpoint id="jmsConsumer"
>                   service="sns:jms-consumer"
>                   endpoint="jmsEndpoint"
>                   targetService="sns:pipeline"
>                   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="yet.another.queue"
> destinationType="javax.jms.Queue" maximumRedeliveries="5"
> initialRedeliveryDelay="10000" useExponentialBackOff="false"/>
>         </jms:activationSpec>
>     </jms:endpoint>
> 
> 
> For this to work you need the following:
> i) declare the activemq resource adapter (#amqResourceAdapter).
> ii) declare a bootstrap context(#bootstrapContext).
> 
> The above can be done with various ways. Here is an example using activemq
> xa-pool:
> 
> 1) Add jencks-amqpool to your classpath.
> 2) Add namespace xmlns:amqpool="http://jencks.org/amqpool/2.0"
> 3) Addx namespace xmlns:amqra="http://activemq.apache.org/schema/ra"
> 4) Declare Jecnks bootstrap context: 
> <bean id="bootstrapContext"
> class="org.jencks.factory.BootstrapContextFactoryBean">
>     <property name="threadPoolSize" value="15"/>
> </bean>
> 5) Declare activemq resource adapter:
> <amqra:resourceAdapter id="amqResourceAdapter"
> serverUrl="tcp://localhost:61616"/>
> 
> The above works for me like a charm. I hope you find it usefull too.
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28230814.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by iocanel <ca...@upstreamsystems.com>.
I had the same issue. A viable work around this issue would be to use the old
endpoints (which seem more mature to me):

    <!-- JMS Consumer -->
    <jms:endpoint id="jmsConsumer"
                  service="sns:jms-consumer"
                  endpoint="jmsEndpoint"
                  targetService="sns:pipeline"
                  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="yet.another.queue"
destinationType="javax.jms.Queue" maximumRedeliveries="5"
initialRedeliveryDelay="10000" useExponentialBackOff="false"/>
        </jms:activationSpec>
    </jms:endpoint>


For this to work you need the following:
i) declare the activemq resource adapter (#amqResourceAdapter).
ii) declare a bootstrap context(#bootstrapContext).

The above can be done with various ways. Here is an example using activemq
xa-pool:

1) Add jencks-amqpool to your classpath.
2) Add namespace xmlns:amqpool="http://jencks.org/amqpool/2.0"
3) Addx namespace xmlns:amqra="http://activemq.apache.org/schema/ra"
4) Declare Jecnks bootstrap context: 
<bean id="bootstrapContext"
class="org.jencks.factory.BootstrapContextFactoryBean">
    <property name="threadPoolSize" value="15"/>
</bean>
5) Declare activemq resource adapter:
<amqra:resourceAdapter id="amqResourceAdapter"
serverUrl="tcp://localhost:61616"/>

The above works for me like a charm. I hope you find it usefull too.
-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28229094.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by gnanda <gi...@phaseforward.com>.

Hi,

Thank you for your quick response.

As per your suggestion  I added below lines to my jms consumer xbean.xml
file and I am getting an exception now.  Here is my xbean.xml file

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
      xmlns:test="http://test" xmlns:amq="http://activemq.org/config/1.0"
      xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
      
      xsi:schemaLocation="http://servicemix.apache.org/jms/1.0
http://servicemix.apache.org/schema/servicemix-jms-3.2.3.xsd
       http://activemq.org/config/1.0
http://activemq.apache.org/schema/core/activemq-core-4.1.1.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
 
      
 
      <jms:consumer service="test:MyConsumerService" endpoint="jms"
            targetService="test:MyBeanConsumerService"
targetEndpoint="beanendpoint"
            destinationName="spq2" connectionFactory="#connectionFactory"
            concurrentConsumers="4" cacheLevel="3" marshaler="#marshaler"
            transacted="jms" />
 
      <!--
            END SNIPPET: consumer <jms:endpoint
service="test:MyConsumerService"
            endpoint="jms+soap"
targetInterfaceName="test:MyConsumerInterface"
            role="consumer" destinationStyle="queue"
            jmsProviderDestinationName="queue/A/Soap" soap="true"
            defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
            connectionFactory="#connectionFactory" />
      -->
      <bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="tcp://localhost:61616" />
            <!--
                  not working <property name="redeliveryPolicy"
ref="redeliveryPolicy"
                  />
            -->
      </bean>
      <bean id="redeliveryPolicy"
class="org.apache.activemq.RedeliveryPolicy">
            <property name="maximumRedeliveries" value="8" />
      </bean>
      
<bean id="marshaler"
           
class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
            <property name="mep"
value="http://www.w3.org/2004/08/wsdl/in-out  
" />
            <property name="rollbackOnError" value="true" />
      </bean>
 
      
 
</beans>
 
 
Exception below:
Do I need to start a transaction explicitly somewhere? If yes, how would I
start a transaction?
 
2010-04-12 21:58:49,342| 21:58:49,342 | WARN  | tenerContainer-7 |
DefaultMessageListenerContainer  | AbstractMessageListenerContainer  646 |
Execution of JMS message listener failed
javax.jms.JMSException: Error sending JBI exchange
                at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
                at
org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
                at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
                at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
                at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
                at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
                at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
                at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
                at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
                at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
                at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.Exception: ERROR:Fault occurred<?xml version="1.0"
encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault
xmlns:axis2ns31="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>axis2ns31:Client</faultcode><faultstring>The
endpoint reference (EPR) for the Operation not found is
http://localhost/axis2/services/EchoService and the WSA Action =
null</faultstring><detail/></soapenv:Fault></soapenv:Body></soapenv:Envelope>
                at
org.simpleBeanconsumer.MyBean.onMessageExchange(MyBean.java:147)
                at
org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:230)
                at
org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:217)
                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)
                ... 1 more
2010-04-12 21:58:49,342| 21:58:49,342 | ERROR | //127.0.0.1:4933 | Service                         
| ivemq.broker.TransportConnection  290 | Async error occurred:
javax.jms.JMSException: Transaction
'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
javax.jms.JMSException: Transaction
'TX:ID:LPF004689-4862-1271123912874-0:65:3' has not been started.
                at
org.apache.activemq.broker.TransactionBroker.getTransaction(TransactionBroker.java:270)
                at
org.apache.activemq.broker.TransactionBroker.acknowledge(TransactionBroker.java:190)
                at
org.apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
                at
org.apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74)
                at
org.apache.activemq.broker.MutableBrokerFilter.acknowledge(MutableBrokerFilter.java:85)
                at
org.apache.activemq.broker.TransportConnection.processMessageAck(TransportConnection.java:456)
                at
org.apache.activemq.command.MessageAck.visit(MessageAck.java:205)
                at
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:305)
                at
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179)
                at
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
                at
org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
                at
org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
                at
org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
                at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:203)
                at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
                at java.lang.Thread.run(Thread.java:619)
 
Thanks & Regards
Gita
 





Freeman Fang wrote:
> 
> Hi,
> 
> You can simply add
> 			marshaler="#marshaler"
>                        transacted="jms"
> attribute for your jms consumer to enable transaction.
> here the marshaler is,
>     <bean id="marshaler"  
> class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
>         <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out 
> " />
>         <property name="rollbackOnError" value="true"/>
>      </bean>
>   notice you must set <property name="rollbackOnError" value="true"/>
> 
> then when a Error message back to your jms consumer, the jms comsumer  
> will do rollback.
> 
> 
> Freeman
> 
> 
> On 2010-4-10, at 下午12:26, gnanda wrote:
> 
>>
>> Hi,
>> I am a newbie in servicemix.
>> I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a  
>> service
>> assembly with 3 SUs. The flow is as below
>> JMS consumer ->servicemix Bean class-> http provider (accessing  
>> external
>> webservice).  I like to understand how would I impose transactional
>> capability the the above message flow
>>
>> For example: if I receive any error (or fault) while calling the  
>> external
>> service from http provider component then I should be able to  
>> rollback  or
>> commit the message to the queue based one the error code.
>>
>> Any insight will be very helpful. Thank you in advance.
>>
>>
>> Here is my xbean definition of jms consumer
>>
>> <jms:consumer service="test:MyConsumerService" endpoint="jms"
>> 		targetService="test:MyBeanConsumerService"  
>> targetEndpoint="beanendpoint"
>> 		destinationName="spq2" connectionFactory="#connectionFactory"
>> 		concurrentConsumers="4" cacheLevel="3" />
>>
>> 	<bean id="connectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>> 		<property name="brokerURL" value="tcp://localhost:61616" />
>> 		<!--
>> 			not working <property name="redeliveryPolicy"  
>> ref="redeliveryPolicy"
>> 			/>
>> 		-->
>> 	</bean>
>> 	<bean id="redeliveryPolicy"  
>> class="org.apache.activemq.RedeliveryPolicy">
>> 		<property name="maximumRedeliveries" value="8" />
>> 	</bean>
>> Here is my xbean definition of the bean class
>> <bean:endpoint service="test:MyBeanConsumerService"  
>> endpoint="beanendpoint"
>> bean="#myBean"/>
>>
>>  <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>
>>
>> </beans>
>>
>> Here is my xbean definition of the http provider
>>
>> <http:endpoint service="test:TemperatureConverterService1"
>>                 endpoint="TemperatureConverterServiceSoap12Binding"
>>                 role="provider"
>>
>> locationURI="http://localhost/axis2/services/TemperatureConverterService 
>> "
>>
>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                 />
>> <!--
>> wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl 
>> "
>> -->
>> </beans>
>> -- 
>> View this message in context:
>> http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
> 
> 
> -- 
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28219212.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SMX4 handling transaction

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

You can simply add
			marshaler="#marshaler"
                       transacted="jms"
attribute for your jms consumer to enable transaction.
here the marshaler is,
    <bean id="marshaler"  
class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler">
        <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out 
" />
        <property name="rollbackOnError" value="true"/>
     </bean>
  notice you must set <property name="rollbackOnError" value="true"/>

then when a Error message back to your jms consumer, the jms comsumer  
will do rollback.


Freeman


On 2010-4-10, at 下午12:26, gnanda wrote:

>
> Hi,
> I am a newbie in servicemix.
> I am using servicemix 4 (apache-servicemix-4.0.0) . I have created a  
> service
> assembly with 3 SUs. The flow is as below
> JMS consumer ->servicemix Bean class-> http provider (accessing  
> external
> webservice).  I like to understand how would I impose transactional
> capability the the above message flow
>
> For example: if I receive any error (or fault) while calling the  
> external
> service from http provider component then I should be able to  
> rollback  or
> commit the message to the queue based one the error code.
>
> Any insight will be very helpful. Thank you in advance.
>
>
> Here is my xbean definition of jms consumer
>
> <jms:consumer service="test:MyConsumerService" endpoint="jms"
> 		targetService="test:MyBeanConsumerService"  
> targetEndpoint="beanendpoint"
> 		destinationName="spq2" connectionFactory="#connectionFactory"
> 		concurrentConsumers="4" cacheLevel="3" />
>
> 	<bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
> 		<property name="brokerURL" value="tcp://localhost:61616" />
> 		<!--
> 			not working <property name="redeliveryPolicy"  
> ref="redeliveryPolicy"
> 			/>
> 		-->
> 	</bean>
> 	<bean id="redeliveryPolicy"  
> class="org.apache.activemq.RedeliveryPolicy">
> 		<property name="maximumRedeliveries" value="8" />
> 	</bean>
> Here is my xbean definition of the bean class
> <bean:endpoint service="test:MyBeanConsumerService"  
> endpoint="beanendpoint"
> bean="#myBean"/>
>
>  <bean id="myBean" class="org.simpleBeanconsumer.MyBean"/>
>
> </beans>
>
> Here is my xbean definition of the http provider
>
> <http:endpoint service="test:TemperatureConverterService1"
>                 endpoint="TemperatureConverterServiceSoap12Binding"
>                 role="provider"
>
> locationURI="http://localhost/axis2/services/TemperatureConverterService 
> "
>
>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                 />
> <!--
> wsdlResource="http://localhost/axis2/services/TemperatureConverterService?wsdl 
> "
> -->
> </beans>
> -- 
> View this message in context: http://old.nabble.com/SMX4-handling-transaction-tp28199896p28199896.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com