Andrea,

Let me try to work out a patch that handles InOut correctly in a synchronous way for backward compatibility and uses asynchronous messaging whenever possible. Could you give that a test run then?

Regards,

Gert

Andrea Zoppello wrote:
Hi Gert,

Waht about to make a route implementation so when an InOut Exchange arrives it will automatically call the answer method.

BTW i cannot figure a usecase where you need to send an InOut exchange to a drools component and then rerouting this InOut exchange to another endpoint.

As i said to Lars if you need this capabilities you could use other components, not drools.

Andrea

Andrea
Gert Vanthienen ha scritto:
Andrea,

Yeah, we should definitely get asynchronous support for Drools so we need to get this done. If the route() method before was able to handle InOut exchanges, we should make sure it still does to avoid breaking people's existing code though -- how about replacing the Exception being thrown at the end by a WARN log statement saying the same thing but still handling the Exchange in a synchronous way as before? This way, we still encourage people to start using answer().

Gert

Andrea Zoppello wrote:
Ok Gert,

Probably i miss to handle the error case, but except for this, i ensure i've stressed with load test the components and it works correcly, under heavvy load.

My suggestion is to start from my code to handle error case, and to commit this.

Do you agree is better to use helper.route for (InOnly / Robust InOnly ) and helper.answer for InOut??

Andrea
Gert Vanthienen ha scritto:
Andrea,

And what if the InOnly MessageExchange you forwarded ends in ERROR? The solution you proposed already answered the incoming exchange with DONE by the time you figure that out. And I think the same goes for RobustInOnly's fault message.

Regards,

Gert

Andrea Zoppello wrote:
Hi Gert,

The route method in my opinion is to handle inonly or robust inonly exchange, if you want to answer you could use the answer method.

In my opinion you must choose what you want to do when you write drools file.

If you need to forward ( creating another exhange ) an InOnly exchange use helper.route instead you need to use helper.answer.

This should cover all the case.

Andrea
Gert Vanthienen ha scritto:
Andrea,

Actually, I was just looking at applying that. If the code in your last comment goes into the routeTo method, isn't this a step back from where we were? It uses send() instead of sendSync(), but I no longer see any possibility of handling an InOut or RobustInOnly with a Fault message, or am I missing something there?

Regards,

Gert

Andrea Zoppello wrote:
Hi,

I had the same problem, take a look to mine last comment on
https://issues.apache.org/activemq/browse/SM-1248

Andrea
gigeril ha scritto:
Hi @ all.
I've following following setup of Servicemix:
TCP Client -----> TCP BC-->drools BC ------> TCP BC ---> TCP Server |____>HTTP BC -->
HTTP Server

If I connect (target Service) my own written TCP BC to the HTTP BC or the
TCP BC it works fine (sync, async, Pattern: Inout, InOnly).
I get a problem if the drools engine get into the message chain. Then I only can send 23 Messages (always 23!!) until my tcp client reports me a connection timeout and the connectors get stuck. I can only press STRG+C in the Servicemix Console Window to restart Servicemix and send 23 Messages. This sending of this 23 Messages work fine. They take the way I defined in my .drl where it depends on the message content if it is send to the tcp or
the http server. I also get the response back to the client.

This is the output when I press STRG+C. This whole stacktrace is printed out
23 times.

INFO - ServiceAssemblyLifeCycle - Shutting down service assembly:
droolsrouter-sa
INFO - ServiceUnitLifeCycle - Shutting down service unit:
droolsrouter-su
INFO - ServiceUnitLifeCycle - Shutting down service unit:
httpprovider-su
INFO - ServiceUnitLifeCycle - Shutting down service unit:
tcpconsumer-su
INFO - ServiceUnitLifeCycle - Shutting down service unit:
tcpprovider-su
INFO  - JBIContainer                   - ServiceMix JBI Container
(ServiceMix) stopped
[Fatal Error] :1:89: Content is not allowed in trailing section.
ERROR - DroolsComponent - Error processing exchange InOut[
  id: ID:10.22.20.113-11b93600c6f-4:0
  status: Active
  role: provider
  service: {http://knapp.com/tcphttp}myRouter
  endpoint: myRouter
  in: <?xml version="1.0" encoding="UTF-8"?><message
type="http"><text>hallo</text></message>
out: Unable to display: org.xml.sax.SAXParseException: Content is not
allowed in trailing section.
]
org.drools.spi.ConsequenceException: javax.jbi.messaging.MessagingException:
java.lang.InterruptedException
        at
org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:13
)
        at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:558)
        at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
        at
org.apache.servicemix.drools.DroolsEndpoint.drools(DroolsEndpoint.java:183)
        at
org.apache.servicemix.drools.DroolsEndpoint.process(DroolsEndpoint.java:177)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:597)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:548)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:502)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: javax.jbi.messaging.MessagingException:
java.lang.InterruptedException
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:498)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:442)
        at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:102)
        at
org.apache.servicemix.drools.model.JbiHelper.routeTo(JbiHelper.java:151)
        at
org.apache.servicemix.drools.model.JbiHelper.route(JbiHelper.java:109)
        at
org.apache.servicemix.drools.Rule_tcphttp_http_0.consequence(Rule_tcphttp_http_0.java:14)
        at
org.apache.servicemix.drools.Rule_tcphttp_http_0ConsequenceInvoker.evaluate(Rule_tcphttp_http_0ConsequenceInv
oker.java:20)
        at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)
        ... 16 more
Caused by: java.lang.InterruptedException
        at java.lang.Object.wait(Native Method)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.waitForExchange(DeliveryChannelImpl.java:699)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:472)
        ... 23 more
ERROR - DroolsComponent - Error setting exchange status to
ERROR
java.lang.IllegalStateException: component is not owner when trying to set
error: org.drools.spi.ConsequenceException: j
avax.jbi.messaging.MessagingException: java.lang.InterruptedException
        at
org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setError(MessageExchangeImpl.java:264)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:516)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.drools.spi.ConsequenceException:
javax.jbi.messaging.MessagingException: java.lang.InterruptedException
        at
org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:13
)
        at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:558)
        at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
        at
org.apache.servicemix.drools.DroolsEndpoint.drools(DroolsEndpoint.java:183)
        at
org.apache.servicemix.drools.DroolsEndpoint.process(DroolsEndpoint.java:177)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:597)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:548)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:502)
        ... 8 more
Caused by: javax.jbi.messaging.MessagingException:
java.lang.InterruptedException
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:498)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:442)
        at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:102)
        at
org.apache.servicemix.drools.model.JbiHelper.routeTo(JbiHelper.java:151)
        at
org.apache.servicemix.drools.model.JbiHelper.route(JbiHelper.java:109)
        at
org.apache.servicemix.drools.Rule_tcphttp_http_0.consequence(Rule_tcphttp_http_0.java:14)
        at
org.apache.servicemix.drools.Rule_tcphttp_http_0ConsequenceInvoker.evaluate(Rule_tcphttp_http_0ConsequenceInv
oker.java:20)
        at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)
        ... 16 more
Caused by: java.lang.InterruptedException
        at java.lang.Object.wait(Native Method)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.waitForExchange(DeliveryChannelImpl.java:699)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:472)
        ... 23 more



So my rule.drl looks like:

package org.apache.servicemix.drools
import org.apache.servicemix.drools.model.Exchange;

global org.apache.servicemix.drools.model.JbiHelper jbi;
rule "tcphttp:http"
    when
me : Exchange( status == Exchange.ACTIVE, inmsg : in != null );
        eval( inmsg.xpath("/message/@type = \"http\""))
    then
System.out.println("!!!!!!!!!!!!!!!!!!!!!http!!!!!!!!!!!!!!!!!!!!!!! "); jbi.route( "service:http://knapp.com/tcphttp/dhttp_provider"; );
end

rule "tcphttp:tcp"
    when
me : Exchange( status == Exchange.ACTIVE, inmsg : in != null );
        eval( inmsg.xpath("/message/@type = \"tcp\""));
    then
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!tcp!!!!!!!!!!!!!!!!!! "); jbi.route( "service:http://knapp.com/tcphttp/dtcp_provider"; );
end




My xbean.xml for the drools su:

<beans xmlns:drools="http://servicemix.apache.org/drools/1.0";
       xmlns:tcphttp="http://knapp.com/tcphttp";
       xmlns="http://www.springframework.org/schema/beans";
xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://servicemix.apache.org/drools/1.0
http://servicemix.apache.org/schema/servicemix-drools-3.2.2.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>

  <drools:endpoint service="tcphttp:myRouter"
                   endpoint="myRouter"
                   ruleBaseResource="classpath:rule.drl"
                   namespaceContext="#nsContext" />


  <drools:namespace-context id="nsContext">
    <drools:namespaces>
      <drools:namespace
prefix="tcphttp">http://knapp.com/tcphttp</drools:namespace>
    </drools:namespaces>
  </drools:namespace-context>

</beans>





















Reply via email to