You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by vgen <ev...@bk.ru> on 2006/05/05 12:37:44 UTC

Can not send sync message from Groovy component

Hello All,

Playing with Groovy component I get exception message
"javax.jbi.messaging.MessagingException: Out not supported" when I use
deliveryChannel.send(messageExchange) to send message from groovy script. In
my test scenario I use InOut MEP. Exception is thrown when response is
coming back and ScriptComponent class initializing script environment
invokes populateNamespace(). Here as it is an InOut exchange out message is
created and put into MessageExchange, but it doesn’t take into account that
it is response. Correct me if understand something in a wrong way.

Regards

--
View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4244848
Sent from the ServiceMix - User forum at Nabble.com.


Re: Can not send sync message from Groovy component

Posted by vgen <ev...@bk.ru>.
javax.jbi.messaging.MessagingException: Out not supported
        at
org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(MessageExchangeImpl.java:286)
        at
org.apache.servicemix.components.script.ScriptComponent.populateNamespace(ScriptComponent.java:252)
        at
org.apache.servicemix.components.groovy.GroovyComponent.populateNamespace(GroovyComponent.java:75)
        at
org.apache.servicemix.components.script.ScriptComponent.process(ScriptComponent.java:218)
        at
org.apache.servicemix.components.script.ScriptComponent.onMessageExchange(ScriptComponent.java:100)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:636)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:221)
        at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
        at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:534)
--
View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4248166
Sent from the ServiceMix - User forum at Nabble.com.


Re: Can not send sync message from Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
The script state is not persistent afaik.
This could be enhanced maybe, but you should really use a sendSync, it
would solve all the problems...

Cheers,
Guillaume Nodet

On 5/6/06, vgen <ev...@bk.ru> wrote:
>
> I thought that the same groovy script can do it theoretically. For example it
> is possible to save state using message id stored in 'bindigs' variable. Or
> groovy script can have logic relying on incoming message content.
> --
> View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4262179
> Sent from the ServiceMix - User forum at Nabble.com.
>
>

Re: Can not send sync message from Groovy component

Posted by vgen <ev...@bk.ru>.
I thought that the same groovy script can do it theoretically. For example it
is possible to save state using message id stored in ‘bindigs’ variable. Or
groovy script can have logic relying on incoming message content.
--
View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4262179
Sent from the ServiceMix - User forum at Nabble.com.


Re: Can not send sync message from Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
When using "consumer", i refer to the JBI spec.  A "consumer" consumes
a service from a "provider"...  When the script component receives an
exchange, he acts as a provider.  But when the script sends an
exchange, the component acts as a consumer ;)
Btw, if you send an InOut exchange asynchronously, where do you expect
to handle the response ?

Cheers,
Guillaume Nodet

On 5/6/06, vgen <ev...@bk.ru> wrote:
>
> Thank you for your clarification. Let me disagree with your statement that
> this component wasn't designed to act as consumer - it consumes incoming
> messages sent by another component (when only "in" message was set) but
> fails to recieve responces (when both "in" and "out" messages are set). I
> think that it is a little bit unexpected behaviour for servicemix users :)
>
> Regards
> --
> View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4258571
> Sent from the ServiceMix - User forum at Nabble.com.
>
>

Re: Can not send sync message from Groovy component

Posted by vgen <ev...@bk.ru>.
Thank you for your clarification. Let me disagree with your statement that
this component wasn't designed to act as consumer - it consumes incoming
messages sent by another component (when only "in" message was set) but
fails to recieve responces (when both "in" and "out" messages are set). I
think that it is a little bit unexpected behaviour for servicemix users :)

Regards
--
View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4258571
Sent from the ServiceMix - User forum at Nabble.com.


Re: Can not send sync message from Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
Ok, I see the problem now.
The component has not been designed to support acting as a consumer,
so as you use a send instead of a sendSync, the exchange will come
back to the component (but as a consumer and not as a provider).
You should try to use a sendSync instead, else you will never receive
the response ...

Cheers,
Guillaume Nodet

On 5/5/06, vgen <ev...@bk.ru> wrote:
>
> See below my config file. I encouter this exception using InOut MEP.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>        xmlns:vm="http://servicemix.apache.org/demo/">
>
>     <!-- the JBI container -->
>     <!--<sm:container id="jbi" useMBeanServer="true"
> createMBeanServer="true" dumpStats="true" statsInterval="10" flowName="jms"
> >-->
>     <sm:container id="jbi" useMBeanServer="true" createMBeanServer="true"
> dumpStats="true" statsInterval="10">
>
>         <sm:activationSpecs>
>
>             <sm:activationSpec componentName="httpSndr"
> service="vm:httpSndr" failIfNoDestinationEndpoint="false">
>                 <sm:component>
>                     <bean xmlns="http://xbean.org/schemas/spring/1.0"
> class="org.apache.servicemix.components.http.HttpInvoker">
>                         <property name="url"
> value="http://localhost:7001/my.jsp"/>
>                     </bean>
>                 </sm:component>
>             </sm:activationSpec>
>
>
>
>             <sm:activationSpec componentName="trace"
>                                service="vm:trace">
>                 <sm:component>
>                     <bean xmlns="http://xbean.org/schemas/spring/1.0"
>
> class="org.apache.servicemix.components.util.TraceComponent" />
>                 </sm:component>
>             </sm:activationSpec>
>
>             <sm:activationSpec componentName="trace2"
>                                service="vm:trace2">
>                 <sm:component>
>                     <bean xmlns="http://xbean.org/schemas/spring/1.0"
>
> class="org.apache.servicemix.components.util.TraceComponent" />
>                 </sm:component>
>             </sm:activationSpec>
>
>             <sm:activationSpec componentName="myServiceImpl"
> service="vm:myServiceImpl" failIfNoDestinationEndpoint="false">
>                 <sm:component>
>                     <bean xmlns=""
> class="org.apache.servicemix.components.groovy.GroovyComponent">
>                         <property name="scriptText">
>                             <value>
>                                 <![CDATA[
>                                 import javax.jbi.messaging.*;
>                                 import
> org.apache.servicemix.jbi.jaxp.StringSource;
>                                 import javax.xml.namespace.QName;
>
>                                 System.out.println("class name:
> "+this.class.name);
>
>                                 println "inMessage - " + inMessage
>
>                                 def httpMessageBody="<MSG_BODY/>"
>
>
>                                 MessageExchangeFactory exchangeFactory =
> deliveryChannel.createExchangeFactory();
>                                 MessageExchange messageExchange =
> exchangeFactory.createInOutExchange();
>                                 println "messageExchange.exchangeId - " +
> messageExchange.exchangeId
>                                 NormalizedMessage msg =
> messageExchange.createMessage();
>                                 msg.setContent(new
> StringSource(httpMessageBody));
>                                 messageExchange.setService(new
> QName("http://servicemix.apache.org/demo/","httpSndr"));
>                                 messageExchange.setMessage(msg, "in");
>                                 deliveryChannel.send(messageExchange);
>
>                                 println "****************** End of interface
> *******************"
>
>             ]]>
>                             </value>
>                         </property>
>                     </bean>
>                 </sm:component></sm:activationSpec>
>
>             <sm:activationSpec componentName="filePoller"
>                                destinationService="vm:myServiceImpl"
> service="vm:filePoller">
>                 <sm:component>
>                     <bean xmlns="http://xbean.org/schemas/spring/1.0"
>
> class="org.apache.servicemix.components.file.FilePoller">
>                         <property name="workManager" ref="workManager" />
>                         <property name="file" value="inbox" />
>                         <property name="period" value="1000" />
>                     </bean>
>                 </sm:component>
>             </sm:activationSpec>
>
>         </sm:activationSpecs>
>     </sm:container>
>
>
>
>     <!-- the JCA container -->
>     <bean id="jencks" class="org.jencks.JCAContainer"
>           singleton="true">
>
>         <!-- lets use the default configuration of work manager and
> transaction manager-->
>         <property name="bootstrapContext">
>             <bean
>                     class="org.jencks.factory.BootstrapContextFactoryBean">
>                 <property name="threadPoolSize" value="25" />
>             </bean>
>         </property>
>
>         <!-- the JCA Resource Adapter -->
>         <property name="resourceAdapter">
>             <bean id="activeMQResourceAdapter"
>                   class="org.apache.activemq.ra.ActiveMQResourceAdapter"
> singleton="true">
>                 <property name="serverUrl"
>                           value="tcp://localhost:61616" />
>             </bean>
>         </property>
>     </bean>
>
>     <!-- message broker -->
>     <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
>         <property name="config" value="classpath:activemq.xml" />
>     </bean>
>
>     <bean id="transactionContextManager"
>           class="org.jencks.factory.TransactionContextManagerFactoryBean"/>
>     <bean id="transactionManager"
>           class="org.jencks.factory.GeronimoTransactionManagerFactoryBean"
> />
>
>     <bean id="jmsFactory"
>           class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL">
>                     <value>tcp://localhost:61616</value>
>                 </property>
>             </bean>
>         </property>
>     </bean>
>
>     <!-- the work manager (thread pool) for this container -->
>         <bean id="workManager"
>                 class="org.jencks.factory.WorkManagerFactoryBean">
>                 <property name="threadPoolSize" value="30" />
>         </bean>
>
>
> </beans>
> --
> View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4248956
> Sent from the ServiceMix - User forum at Nabble.com.
>
>

Re: Can not send sync message from Groovy component

Posted by vgen <ev...@bk.ru>.
See below my config file. I encouter this exception using InOut MEP.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
       xmlns:vm="http://servicemix.apache.org/demo/">

    <!-- the JBI container -->
    <!--<sm:container id="jbi" useMBeanServer="true"
createMBeanServer="true" dumpStats="true" statsInterval="10" flowName="jms"
>-->
    <sm:container id="jbi" useMBeanServer="true" createMBeanServer="true"
dumpStats="true" statsInterval="10">

        <sm:activationSpecs>

            <sm:activationSpec componentName="httpSndr"
service="vm:httpSndr" failIfNoDestinationEndpoint="false">
                <sm:component>
                    <bean xmlns="http://xbean.org/schemas/spring/1.0"
class="org.apache.servicemix.components.http.HttpInvoker">
                        <property name="url"
value="http://localhost:7001/my.jsp"/>
                    </bean>
                </sm:component>
            </sm:activationSpec>



            <sm:activationSpec componentName="trace"
                               service="vm:trace">
                <sm:component>
                    <bean xmlns="http://xbean.org/schemas/spring/1.0"
                         
class="org.apache.servicemix.components.util.TraceComponent" />
                </sm:component>
            </sm:activationSpec>

            <sm:activationSpec componentName="trace2"
                               service="vm:trace2">
                <sm:component>
                    <bean xmlns="http://xbean.org/schemas/spring/1.0"
                         
class="org.apache.servicemix.components.util.TraceComponent" />
                </sm:component>
            </sm:activationSpec>

            <sm:activationSpec componentName="myServiceImpl"
service="vm:myServiceImpl" failIfNoDestinationEndpoint="false">
                <sm:component>
                    <bean xmlns=""
class="org.apache.servicemix.components.groovy.GroovyComponent">
                        <property name="scriptText">
                            <value>
                                <![CDATA[
                                import javax.jbi.messaging.*;
                                import
org.apache.servicemix.jbi.jaxp.StringSource;
                                import javax.xml.namespace.QName;

                                System.out.println("class name:
"+this.class.name);

                                println "inMessage - " + inMessage

                                def httpMessageBody="<MSG_BODY/>"


                                MessageExchangeFactory exchangeFactory =
deliveryChannel.createExchangeFactory();
                                MessageExchange messageExchange =
exchangeFactory.createInOutExchange();
                                println "messageExchange.exchangeId - " +
messageExchange.exchangeId
                                NormalizedMessage msg =
messageExchange.createMessage();
                                msg.setContent(new
StringSource(httpMessageBody));
                                messageExchange.setService(new
QName("http://servicemix.apache.org/demo/","httpSndr"));
                                messageExchange.setMessage(msg, "in");
                                deliveryChannel.send(messageExchange);

                                println "****************** End of interface
*******************"

            ]]>
                            </value>
                        </property>
                    </bean>
                </sm:component></sm:activationSpec>

            <sm:activationSpec componentName="filePoller"
                               destinationService="vm:myServiceImpl"
service="vm:filePoller">
                <sm:component>
                    <bean xmlns="http://xbean.org/schemas/spring/1.0"
                         
class="org.apache.servicemix.components.file.FilePoller">
                        <property name="workManager" ref="workManager" />
                        <property name="file" value="inbox" />
                        <property name="period" value="1000" />
                    </bean>
                </sm:component>
            </sm:activationSpec>

        </sm:activationSpecs>
    </sm:container>



    <!-- the JCA container -->
    <bean id="jencks" class="org.jencks.JCAContainer"
          singleton="true">

        <!-- lets use the default configuration of work manager and
transaction manager-->
        <property name="bootstrapContext">
            <bean
                    class="org.jencks.factory.BootstrapContextFactoryBean">
                <property name="threadPoolSize" value="25" />
            </bean>
        </property>

        <!-- the JCA Resource Adapter -->
        <property name="resourceAdapter">
            <bean id="activeMQResourceAdapter"
                  class="org.apache.activemq.ra.ActiveMQResourceAdapter"
singleton="true">
                <property name="serverUrl"
                          value="tcp://localhost:61616" />
            </bean>
        </property>
    </bean>

    <!-- message broker -->
    <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
        <property name="config" value="classpath:activemq.xml" />
    </bean>

    <bean id="transactionContextManager"
          class="org.jencks.factory.TransactionContextManagerFactoryBean"/>
    <bean id="transactionManager"
          class="org.jencks.factory.GeronimoTransactionManagerFactoryBean"
/>

    <bean id="jmsFactory"
          class="org.apache.activemq.pool.PooledConnectionFactory">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL">
                    <value>tcp://localhost:61616</value>
                </property>
            </bean>
        </property>
    </bean>

    <!-- the work manager (thread pool) for this container -->
	<bean id="workManager"
		class="org.jencks.factory.WorkManagerFactoryBean">
		<property name="threadPoolSize" value="30" />
	</bean>


</beans>
--
View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4248956
Sent from the ServiceMix - User forum at Nabble.com.


Re: Can not send sync message from Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
Such an exception occurs when dealing with InOnly exchanges ...
Or maybe if you try setting the out message on a new exchange ...
Could you post your script please ?

Cheers,
Guillaume Nodet

On 5/5/06, Guillaume Nodet <gn...@gmail.com> wrote:
> Could you post the full stack trace please ?
>
> Cheers,
> Guillaume Nodet
>
> On 5/5/06, vgen <ev...@bk.ru> wrote:
> >
> > Hello All,
> >
> > Playing with Groovy component I get exception message
> > "javax.jbi.messaging.MessagingException: Out not supported" when I use
> > deliveryChannel.send(messageExchange) to send message from groovy script. In
> > my test scenario I use InOut MEP. Exception is thrown when response is
> > coming back and ScriptComponent class initializing script environment
> > invokes populateNamespace(). Here as it is an InOut exchange out message is
> > created and put into MessageExchange, but it doesn't take into account that
> > it is response. Correct me if understand something in a wrong way.
> >
> > Regards
> >
> > --
> > View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4244848
> > Sent from the ServiceMix - User forum at Nabble.com.
> >
> >
>

Re: Can not send sync message from Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
Could you post the full stack trace please ?

Cheers,
Guillaume Nodet

On 5/5/06, vgen <ev...@bk.ru> wrote:
>
> Hello All,
>
> Playing with Groovy component I get exception message
> "javax.jbi.messaging.MessagingException: Out not supported" when I use
> deliveryChannel.send(messageExchange) to send message from groovy script. In
> my test scenario I use InOut MEP. Exception is thrown when response is
> coming back and ScriptComponent class initializing script environment
> invokes populateNamespace(). Here as it is an InOut exchange out message is
> created and put into MessageExchange, but it doesn't take into account that
> it is response. Correct me if understand something in a wrong way.
>
> Regards
>
> --
> View this message in context: http://www.nabble.com/Can-not-send-sync-message-from-Groovy-component-t1563082.html#a4244848
> Sent from the ServiceMix - User forum at Nabble.com.
>
>