Illegal exchange status

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Illegal exchange status

Mar, Kheng Kok
Hi all. I've just started to use servicemix. I am trying a simple
example of setting up a HttpServer (using the HttpConnector component)
that listens on a specific port which in turn invokes the POJO that
component that returns a text message reply.  I encountered a illegal
exchange status error as shown in the stack trace below, when the code
call done() helper function of Pojo.  I have attached my configuration
and MySender.java  at the end of the mail. Can anyone shed any light on
what can be the cause of this error ?

 ________Stack Trace _________

javax.jbi.messaging.MessagingException: illegal exchange status: done
        at
org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExcha
ngeImpl.java:535)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:346)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImp
l.java:387)
        at
org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
        at MySender.onMessageExchange(Unknown Source)
        at
org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
nge(ComponentAdaptorMEListener.java:48)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
ChannelImpl.java:588)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
)
        at
org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
        at
org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
        at
org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java
:567)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:347)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:422)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:398)
        at
org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBi
nding.java:61)
        at
org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding
.java:46)
        at
org.servicemix.components.http.BindingServlet.doGet(BindingServlet.java:
68)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
        at
org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:65
7)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
        at
org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
        at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
        at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197
)
        at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
        at
org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)

___ servicemix.xml ______________
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xbean.org/schemas/spring/1.0"
        xmlns:spring="http://xbean.org/schemas/spring/1.0"
        xmlns:sm="http://servicemix.org/config/1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
../../conf/spring-beans.xsd
                            http://servicemix.org/config/1.0
../../conf/servicemix.xsd"
        xmlns:my="http://servicemix.org/demo/">


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

                <sm:activationSpecs>
                        <sm:activationSpec componentName="httpReceiver"
service="my:httpBinding" endpoint="httpReceiver" destinationService=
"my:Sender">
                                <sm:component>
                                       <bean
xmlns="http://xbean.org/schemas/spring/1.0"
 
class="org.servicemix.components.http.HttpConnector">
                                          <property name="host"
value="localhost"/>
                                          <property name="port"
value="8089"/>
                                       </bean>
                                </sm:component>
                        </sm:activationSpec>

            <sm:activationSpec componentName="sender"
service="my:Sender">
               <sm:component>
               <spring:bean class="MySender"/>
               </sm:component>
            </sm:activationSpec>

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

</beans>

-- MySender.java ---

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
           done(exchange);

      }  .............

 

Best Regards
Kheng Kok


Reply | Threaded
Open this post in threaded view
|

Re: Illegal exchange status

Guillaume Nodet-2
The legal status changes are described in the jbi spec, section 5.4.2.
In your case, it seems that your exchange is in-out and it seems
that you are calling the done method from your  MySender.onMessageExchange.
This is an illegal transition.  When you receive an in-out exchange, you
can send the
response back (without changing the status), or set an error.  The done
status will
be set by the consumer, which is the HttpInOutBinding.

Cheers,
Guillaume Nodet

Mar, Kheng Kok wrote:

>Hi all. I've just started to use servicemix. I am trying a simple
>example of setting up a HttpServer (using the HttpConnector component)
>that listens on a specific port which in turn invokes the POJO that
>component that returns a text message reply.  I encountered a illegal
>exchange status error as shown in the stack trace below, when the code
>call done() helper function of Pojo.  I have attached my configuration
>and MySender.java  at the end of the mail. Can anyone shed any light on
>what can be the cause of this error ?
>
> ________Stack Trace _________
>
>javax.jbi.messaging.MessagingException: illegal exchange status: done
>        at
>org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExcha
>ngeImpl.java:535)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
>mpl.java:346)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImp
>l.java:387)
>        at
>org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
>        at MySender.onMessageExchange(Unknown Source)
>        at
>org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
>nge(ComponentAdaptorMEListener.java:48)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
>ChannelImpl.java:588)
>        at
>org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
>)
>        at
>org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
>        at
>org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
>        at
>org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
>        at
>org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java
>:567)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
>mpl.java:347)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
>lImpl.java:422)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
>lImpl.java:398)
>        at
>org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBi
>nding.java:61)
>        at
>org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding
>.java:46)
>        at
>org.servicemix.components.http.BindingServlet.doGet(BindingServlet.java:
>68)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>        at
>org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
>        at
>org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:65
>7)
>        at
>org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
>        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
>        at
>org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
>        at
>org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
>        at
>org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
>        at
>org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197
>)
>        at
>org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
>        at
>org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)
>
>___ servicemix.xml ______________
><?xml version="1.0" encoding="UTF-8"?>
><beans xmlns="http://xbean.org/schemas/spring/1.0"
>        xmlns:spring="http://xbean.org/schemas/spring/1.0"
>        xmlns:sm="http://servicemix.org/config/1.0"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
>../../conf/spring-beans.xsd
>                            http://servicemix.org/config/1.0
>../../conf/servicemix.xsd"
>        xmlns:my="http://servicemix.org/demo/">
>
>
>        <!-- the JBI container -->
>        <sm:container spring:id="jbi" useMBeanServer="true"
>                createMBeanServer="true"
>monitorInstallationDirectory="true" dumpStats="true"
>                statsInterval="10">
>
>                <sm:activationSpecs>
>                        <sm:activationSpec componentName="httpReceiver"
>service="my:httpBinding" endpoint="httpReceiver" destinationService=
>"my:Sender">
>                                <sm:component>
>                                       <bean
>xmlns="http://xbean.org/schemas/spring/1.0"
>
>class="org.servicemix.components.http.HttpConnector">
>                                          <property name="host"
>value="localhost"/>
>                                          <property name="port"
>value="8089"/>
>                                       </bean>
>                                </sm:component>
>                        </sm:activationSpec>
>
>            <sm:activationSpec componentName="sender"
>service="my:Sender">
>               <sm:component>
>               <spring:bean class="MySender"/>
>               </sm:component>
>            </sm:activationSpec>
>
>                </sm:activationSpecs>
>        </sm:container>
>
></beans>
>
>-- MySender.java ---
>
>public class MySender extends   PojoSupport  implements
>MessageExchangeListener  {
>
>       public void onMessageExchange(MessageExchange exchange) throws
>MessagingException {
>
>           NormalizedMessage message = exchange.createMessage();
>           message.setContent(new StringSource(getQuote("quote.txt",
>                                     "<quote>3.0</quote>")));
>           done(exchange);
>
>      }  .............
>
>
>
>Best Regards
>Kheng Kok
>
>
>
>
>  
>

Reply | Threaded
Open this post in threaded view
|

RE: Illegal exchange status

yitzhak yitzhaki
In reply to this post by Mar, Kheng Kok
Hi Mar, Kheng Kok

I experienced with a similar  problem also when using http.
The problem is you are using httpConnector that extends HttpInOutBinding
Take a look at the code HttpInOutBinding processInOut method and see
that :

            boolean result = getDeliveryChannel().sendSync(exchange);
            if (result) {
                getMarshaler().toResponse(exchange,
exchange.getOutMessage(), response);
            }
            done(exchange);
            response.setStatus(HttpServletResponse.SC_OK);
Because its inout due to the JBI spec the consumer (HttpConnector must
call done( ) and not provider can't call done )

I think u should change your code from:

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
           done(exchange);

      }  .............

To:

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
++++++++++++++++++++++++++++++++
        //calling send instead of done
           send(exchange);
++++++++++++++++++++++++++++++++

      }  .............

Regards
Yitzhaki Yitzhak

-----Original Message-----
From: Mar, Kheng Kok [mailto:[hidden email]]
Sent: Thursday, December 08, 2005 11:48 AM
To: [hidden email]
Subject: [servicemix-user] Illegal exchange status

Hi all. I've just started to use servicemix. I am trying a simple
example of setting up a HttpServer (using the HttpConnector component)
that listens on a specific port which in turn invokes the POJO that
component that returns a text message reply.  I encountered a illegal
exchange status error as shown in the stack trace below, when the code
call done() helper function of Pojo.  I have attached my configuration
and MySender.java  at the end of the mail. Can anyone shed any light on
what can be the cause of this error ?

 ________Stack Trace _________

javax.jbi.messaging.MessagingException: illegal exchange status: done
        at
org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExcha
ngeImpl.java:535)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:346)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImp
l.java:387)
        at
org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
        at MySender.onMessageExchange(Unknown Source)
        at
org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
nge(ComponentAdaptorMEListener.java:48)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
ChannelImpl.java:588)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
)
        at
org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
        at
org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
        at
org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java
:567)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:347)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:422)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:398)
        at
org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBi
nding.java:61)
        at
org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding
        at
org.servicemix.components.http.BindingServlet.doGet(BindingServlet.java:
68)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
        at
org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:65
7)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
        at
org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
        at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
        at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197
)
        at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
        at
org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)

___ servicemix.xml ______________
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xbean.org/schemas/spring/1.0"
        xmlns:spring="http://xbean.org/schemas/spring/1.0"
        xmlns:sm="http://servicemix.org/config/1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
                            http://servicemix.org/config/1.0
        xmlns:my="http://servicemix.org/demo/">


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

                <sm:activationSpecs>
                        <sm:activationSpec componentName="httpReceiver"
service="my:httpBinding" endpoint="httpReceiver" destinationService=
"my:Sender">
                                <sm:component>
                                       <bean
xmlns="http://xbean.org/schemas/spring/1.0"
 
class="org.servicemix.components.http.HttpConnector">
                                          <property name="host"
value="localhost"/>
                                          <property name="port"
value="8089"/>
                                       </bean>
                                </sm:component>
                        </sm:activationSpec>

            <sm:activationSpec componentName="sender"
service="my:Sender">
               <sm:component>
               <spring:bean class="MySender"/>
               </sm:component>
            </sm:activationSpec>

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

</beans>

-- MySender.java ---

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
           done(exchange);

      }  .............

 

Best Regards
Kheng Kok



______________________________________________________________________
  This email message has been scanned by PineApp Mail-Secure and has
been found clean.


Reply | Threaded
Open this post in threaded view
|

RE: Illegal exchange status

Mar, Kheng Kok
In reply to this post by Mar, Kheng Kok
Thanks Yitzhaki and Guillaume for the pointer. I have tried changing the
done() to send(). Though I am able to get a response back this time
round without the invalid exchange status, However, I noticed that the
onMessageExchange() of MySender.java is invoked two times. The first
time it is invoked, no error is encountered and I get the response from
MySender back ok. The 2nd time it is invoked it throws an error
complaining :

javax.jbi.messaging.MessagingException: Out not supported
        at
org.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(MessageExcha
ngeImpl.java:275)
        at MySender.onMessageExchange(MySender.java:35)
        at
org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
nge(ComponentAdaptorMEListener.java:48)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
ChannelImpl.java:588)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
)
        at
org.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:225)
        at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:
291)
        at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
Source)

I have attached the remote debugger to trace the program flows, and
noticed that the first time, the "state" variable in MessageExchangeImpl
instance is 1 and when checked against the state transition table (in
the can() function), it turned out ok (CAN_SET_OUT_MSG)  But when it is
invoked second time (which it shouldn't and I am not sure why), the
state changes to 3 and checked against the state table, it fails the
CAN_SET_OUT_MSG check.


My question is why is MySender invoked two times ? Is there anything
wrong with my configuration ?

Rgds
Kheng Kok


-----Original Message-----
From: yitzhak yitzhaki [mailto:[hidden email]]
Sent: Thursday, December 08, 2005 6:01 PM
To: [hidden email]
Subject: RE: [servicemix-user] Illegal exchange status

Hi Mar, Kheng Kok

I experienced with a similar  problem also when using http.
The problem is you are using httpConnector that extends HttpInOutBinding
Take a look at the code HttpInOutBinding processInOut method and see
that :

            boolean result = getDeliveryChannel().sendSync(exchange);
            if (result) {
                getMarshaler().toResponse(exchange,
exchange.getOutMessage(), response);
            }
            done(exchange);
            response.setStatus(HttpServletResponse.SC_OK);
Because its inout due to the JBI spec the consumer (HttpConnector must
call done( ) and not provider can't call done )

I think u should change your code from:

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
           done(exchange);

      }  .............

To:

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
++++++++++++++++++++++++++++++++
        //calling send instead of done
           send(exchange);
++++++++++++++++++++++++++++++++

      }  .............

Regards
Yitzhaki Yitzhak

-----Original Message-----
From: Mar, Kheng Kok [mailto:[hidden email]]
Sent: Thursday, December 08, 2005 11:48 AM
To: [hidden email]
Subject: [servicemix-user] Illegal exchange status

Hi all. I've just started to use servicemix. I am trying a simple
example of setting up a HttpServer (using the HttpConnector component)
that listens on a specific port which in turn invokes the POJO that
component that returns a text message reply.  I encountered a illegal
exchange status error as shown in the stack trace below, when the code
call done() helper function of Pojo.  I have attached my configuration
and MySender.java  at the end of the mail. Can anyone shed any light on
what can be the cause of this error ?

 ________Stack Trace _________

javax.jbi.messaging.MessagingException: illegal exchange status: done
        at
org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExcha
ngeImpl.java:535)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:346)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImp
l.java:387)
        at
org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
        at MySender.onMessageExchange(Unknown Source)
        at
org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
nge(ComponentAdaptorMEListener.java:48)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
ChannelImpl.java:588)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
)
        at
org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
        at
org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
        at
org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
        at
org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java
:567)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
mpl.java:347)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:422)
        at
org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
lImpl.java:398)
        at
org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBi
nding.java:61)
        at
org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding
        at
org.servicemix.components.http.BindingServlet.doGet(BindingServlet.java:
68)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
        at
org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:65
7)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
        at
org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
        at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
        at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197
)
        at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
        at
org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)

___ servicemix.xml ______________
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xbean.org/schemas/spring/1.0"
        xmlns:spring="http://xbean.org/schemas/spring/1.0"
        xmlns:sm="http://servicemix.org/config/1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
                            http://servicemix.org/config/1.0
        xmlns:my="http://servicemix.org/demo/">


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

                <sm:activationSpecs>
                        <sm:activationSpec componentName="httpReceiver"
service="my:httpBinding" endpoint="httpReceiver" destinationService=
"my:Sender">
                                <sm:component>
                                       <bean
xmlns="http://xbean.org/schemas/spring/1.0"
 
class="org.servicemix.components.http.HttpConnector">
                                          <property name="host"
value="localhost"/>
                                          <property name="port"
value="8089"/>
                                       </bean>
                                </sm:component>
                        </sm:activationSpec>

            <sm:activationSpec componentName="sender"
service="my:Sender">
               <sm:component>
               <spring:bean class="MySender"/>
               </sm:component>
            </sm:activationSpec>

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

</beans>

-- MySender.java ---

public class MySender extends   PojoSupport  implements
MessageExchangeListener  {

       public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

           NormalizedMessage message = exchange.createMessage();
           message.setContent(new StringSource(getQuote("quote.txt",
                                     "<quote>3.0</quote>")));
           done(exchange);

      }  .............

 

Best Regards
Kheng Kok



______________________________________________________________________
  This email message has been scanned by PineApp Mail-Secure and has
been found clean.



Reply | Threaded
Open this post in threaded view
|

Re: Illegal exchange status

Guillaume Nodet
Administrator
This is because you are receiving the DONE status.
You have to check the status of the message, before trying to handle it.
   ACTIVE => process
   ERROR => return DONE
   DONE => do nothing

Guillaume

Mar, Kheng Kok wrote:

>Thanks Yitzhaki and Guillaume for the pointer. I have tried changing the
>done() to send(). Though I am able to get a response back this time
>round without the invalid exchange status, However, I noticed that the
>onMessageExchange() of MySender.java is invoked two times. The first
>time it is invoked, no error is encountered and I get the response from
>MySender back ok. The 2nd time it is invoked it throws an error
>complaining :
>
>javax.jbi.messaging.MessagingException: Out not supported
>        at
>org.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(MessageExcha
>ngeImpl.java:275)
>        at MySender.onMessageExchange(MySender.java:35)
>        at
>org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
>nge(ComponentAdaptorMEListener.java:48)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
>ChannelImpl.java:588)
>        at
>org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
>)
>        at
>org.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:225)
>        at
>org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:
>291)
>        at
>EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
>Source)
>
>I have attached the remote debugger to trace the program flows, and
>noticed that the first time, the "state" variable in MessageExchangeImpl
>instance is 1 and when checked against the state transition table (in
>the can() function), it turned out ok (CAN_SET_OUT_MSG)  But when it is
>invoked second time (which it shouldn't and I am not sure why), the
>state changes to 3 and checked against the state table, it fails the
>CAN_SET_OUT_MSG check.
>
>
>My question is why is MySender invoked two times ? Is there anything
>wrong with my configuration ?
>
>Rgds
>Kheng Kok
>
>
>-----Original Message-----
>From: yitzhak yitzhaki [mailto:[hidden email]]
>Sent: Thursday, December 08, 2005 6:01 PM
>To: [hidden email]
>Subject: RE: [servicemix-user] Illegal exchange status
>
>Hi Mar, Kheng Kok
>
>I experienced with a similar  problem also when using http.
>The problem is you are using httpConnector that extends HttpInOutBinding
>Take a look at the code HttpInOutBinding processInOut method and see
>that :
>
>            boolean result = getDeliveryChannel().sendSync(exchange);
>            if (result) {
>                getMarshaler().toResponse(exchange,
>exchange.getOutMessage(), response);
>            }
>            done(exchange);
>            response.setStatus(HttpServletResponse.SC_OK);
>Because its inout due to the JBI spec the consumer (HttpConnector must
>call done( ) and not provider can't call done )
>
>I think u should change your code from:
>
>public class MySender extends   PojoSupport  implements
>MessageExchangeListener  {
>
>       public void onMessageExchange(MessageExchange exchange) throws
>MessagingException {
>
>           NormalizedMessage message = exchange.createMessage();
>           message.setContent(new StringSource(getQuote("quote.txt",
>                                     "<quote>3.0</quote>")));
>           done(exchange);
>
>      }  .............
>
>To:
>
>public class MySender extends   PojoSupport  implements
>MessageExchangeListener  {
>
>       public void onMessageExchange(MessageExchange exchange) throws
>MessagingException {
>
>           NormalizedMessage message = exchange.createMessage();
>           message.setContent(new StringSource(getQuote("quote.txt",
>                                     "<quote>3.0</quote>")));
>++++++++++++++++++++++++++++++++
> //calling send instead of done
>           send(exchange);
>++++++++++++++++++++++++++++++++
>
>      }  .............
>
>Regards
>Yitzhaki Yitzhak
>
>-----Original Message-----
>From: Mar, Kheng Kok [mailto:[hidden email]]
>Sent: Thursday, December 08, 2005 11:48 AM
>To: [hidden email]
>Subject: [servicemix-user] Illegal exchange status
>
>Hi all. I've just started to use servicemix. I am trying a simple
>example of setting up a HttpServer (using the HttpConnector component)
>that listens on a specific port which in turn invokes the POJO that
>component that returns a text message reply.  I encountered a illegal
>exchange status error as shown in the stack trace below, when the code
>call done() helper function of Pojo.  I have attached my configuration
>and MySender.java  at the end of the mail. Can anyone shed any light on
>what can be the cause of this error ?
>
> ________Stack Trace _________
>
>javax.jbi.messaging.MessagingException: illegal exchange status: done
>        at
>org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExcha
>ngeImpl.java:535)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
>mpl.java:346)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImp
>l.java:387)
>        at
>org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
>        at MySender.onMessageExchange(Unknown Source)
>        at
>org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExcha
>nge(ComponentAdaptorMEListener.java:48)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(Delivery
>ChannelImpl.java:588)
>        at
>org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171
>)
>        at
>org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
>        at
>org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
>        at
>org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
>        at
>org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java
>:567)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelI
>mpl.java:347)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
>lImpl.java:422)
>        at
>org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChanne
>lImpl.java:398)
>        at
>org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBi
>nding.java:61)
>        at
>org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding
>        at
>org.servicemix.components.http.BindingServlet.doGet(BindingServlet.java:
>68)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>        at
>org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
>        at
>org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:65
>7)
>        at
>org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
>        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
>        at
>org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
>        at
>org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
>        at
>org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
>        at
>org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197
>)
>        at
>org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
>        at
>org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)
>
>___ servicemix.xml ______________
><?xml version="1.0" encoding="UTF-8"?>
><beans xmlns="http://xbean.org/schemas/spring/1.0"
>        xmlns:spring="http://xbean.org/schemas/spring/1.0"
>        xmlns:sm="http://servicemix.org/config/1.0"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
>                            http://servicemix.org/config/1.0
>        xmlns:my="http://servicemix.org/demo/">
>
>
>        <!-- the JBI container -->
>        <sm:container spring:id="jbi" useMBeanServer="true"
>                createMBeanServer="true"
>monitorInstallationDirectory="true" dumpStats="true"
>                statsInterval="10">
>
>                <sm:activationSpecs>
>                        <sm:activationSpec componentName="httpReceiver"
>service="my:httpBinding" endpoint="httpReceiver" destinationService=
>"my:Sender">
>                                <sm:component>
>                                       <bean
>xmlns="http://xbean.org/schemas/spring/1.0"
>
>class="org.servicemix.components.http.HttpConnector">
>                                          <property name="host"
>value="localhost"/>
>                                          <property name="port"
>value="8089"/>
>                                       </bean>
>                                </sm:component>
>                        </sm:activationSpec>
>
>            <sm:activationSpec componentName="sender"
>service="my:Sender">
>               <sm:component>
>               <spring:bean class="MySender"/>
>               </sm:component>
>            </sm:activationSpec>
>
>                </sm:activationSpecs>
>        </sm:container>
>
></beans>
>
>-- MySender.java ---
>
>public class MySender extends   PojoSupport  implements
>MessageExchangeListener  {
>
>       public void onMessageExchange(MessageExchange exchange) throws
>MessagingException {
>
>           NormalizedMessage message = exchange.createMessage();
>           message.setContent(new StringSource(getQuote("quote.txt",
>                                     "<quote>3.0</quote>")));
>           done(exchange);
>
>      }  .............
>
>
>
>Best Regards
>Kheng Kok
>
>
>
>______________________________________________________________________
>  This email message has been scanned by PineApp Mail-Secure and has
>been found clean.
>
>
>
>
>
>  
>