Discussion:
Choice Message Processor
Harish S
2012-02-15 11:54:51 UTC
Permalink
Hi guys i am trying to check the presence of some data in a database table, if the data is present then it should perform some action else it should perform some other action. i have stuck in the choice message processor's when expression. anyone plz help me in solving the problem.

Error i am getting is

ERROR 2012-02-15 17:21:42,886 [test.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to route event via endpoint: null. Message payload is of type: CaseInsensitiveHashMap
Code : MULE_ERROR-39999
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.routing.filters.ExpressionFilter:140 (null)
2. Failed to route event via endpoint: null. Message payload is of type: CaseInsensitiveHashMap (org.mule.api.routing.RoutingException)
org.mule.routing.outbound.AbstractOutboundRouter:175 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/routing/RoutingException.html)

Code which i have used is given below:


<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:xm="http://www.mulesoft.org/schema/mule/xml" xmlns:jdbc="http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"

xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.2/mule-xml.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/3.2/mule-jdbc-ee.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd">


<spring:bean id="jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName"
value="oracle.jdbc.driver.OracleDriver" />
<spring:property name="url"
value="jdbc:oracle:thin:hr/manage-vegXm4Wwwz4S9fsqc+***@public.gmane.org:1521:wmdb" />
</spring:bean>

<jdbc:connector name="jdbcConnector1" pollingFrequency="1000"
dataSource-ref="jdbcDataSource" transactionPerMessage="true">
<jdbc:query key="SelectAssociateFromTVDB"
value="select count(*) as test from TRAVEL_VENDOR_EMPL_DETAILS where ASSOCIATE_ID='303250' AND PROCESSED='Y'" />
<jdbc:query key="SelectAssociateFromTVDB.ack"
value="update TRAVEL_VENDOR_EMPL_DETAILS set PROCESSED='Y' where ASSOCIATE_ID ='303250' AND PROCESSED!='Y'" />
</jdbc:connector>

<vm:endpoint name="A" path="TravelVendor" />

<flow name="TravelVendor">
<file:inbound-endpoint
path="C:\Users\303250\Desktop\Mule\Mule_Integration_PoC\TV\Inbound">
<file:filename-wildcard-filter pattern="Associate_Travel_Details.xml" />
</file:inbound-endpoint>

<log-component />
<byte-array-to-string-transformer
name="ByteArrayToString" />


<vm:outbound-endpoint ref="A" />

</flow>


<flow name="test">
<composite-source>
<vm:inbound-endpoint ref="A" />
<jdbc:inbound-endpoint queryKey="SelectAssociateFromTVDB" />
</composite-source>
<all>
<jdbc:outbound-endpoint queryKey="SelectAssociateFromTVDB.ack" />

<choice>
<when expression="#[map-Payload:[TEST==1]]">
<stdio:outbound-endpoint name="out" system="OUT"
exchange-pattern="one-way" />
</when>
<otherwise>
<file:outbound-endpoint
path="C:\Users\303250\Desktop\Mule\Mule_Integration_PoC\TV" />
</otherwise>
</choice>


</all>
</flow>

</mule>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Mariano Capurro
2012-02-15 12:09:56 UTC
Permalink
I think the problem is with the expression #[map-Payload:[TEST==1]]


The evaluator map-payload will assume the Payload is of type map and the
expression is the key to that map. For example:
#[map-payload:Name]

Will return the value for the key 'Name' in the map.

You may want to use the groovy evaluator instead. For example:

#[groovy:payload.get('TEST') == 1]

Or use any other groovy expression (payload is a variable that get's
injected to the script so that you can use it)

Kind regards
Post by Harish S
Hi guys i am trying to check the presence of some data in a database
table, if the data is present then it should perform some action else it
should perform some other action. i have stuck in the choice message
processor's when expression. anyone plz help me in solving the problem.
Error i am getting is
ERROR 2012-02-15 17:21:42,886 [test.stage1.02]
********************************************************************************
Message : Failed to route event via endpoint: null. Message
payload is of type: CaseInsensitiveHashMap
Code : MULE_ERROR-39999
--------------------------------------------------------------------------------
1. null (java.lang.NullPointerException)
org.mule.routing.filters.ExpressionFilter:140 (null)
CaseInsensitiveHashMap (org.mule.api.routing.RoutingException)
org.mule.routing.outbound.AbstractOutboundRouter:175 (
http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/routing/RoutingException.html
)
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:xm="http://www.mulesoft.org/schema/mule/xml" xmlns:jdbc="
http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:stdio="
http://www.mulesoft.org/schema/mule/stdio"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/vm
http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/xml
http://www.mulesoft.org/schema/mule/xml/3.2/mule-xml.xsd
http://www.mulesoft.org/schema/mule/stdio
http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc
http://www.mulesoft.org/schema/mule/ee/jdbc/3.2/mule-jdbc-ee.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/file
http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd">
<spring:bean id="jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource"
destroy-method="shutdown">
<spring:property name="driverName"
value="oracle.jdbc.driver.OracleDriver" />
<spring:property name="url"
/>
</spring:bean>
<jdbc:connector name="jdbcConnector1" pollingFrequency="1000"
dataSource-ref="jdbcDataSource"
transactionPerMessage="true">
<jdbc:query key="SelectAssociateFromTVDB"
value="select count(*) as test from
TRAVEL_VENDOR_EMPL_DETAILS where ASSOCIATE_ID='303250' AND PROCESSED='Y'" />
<jdbc:query key="SelectAssociateFromTVDB.ack"
value="update TRAVEL_VENDOR_EMPL_DETAILS set
PROCESSED='Y' where ASSOCIATE_ID ='303250' AND PROCESSED!='Y'" />
</jdbc:connector>
<vm:endpoint name="A" path="TravelVendor" />
<flow name="TravelVendor">
<file:inbound-endpoint
path="C:\Users\303250\Desktop\Mule\Mule_Integration_PoC\TV\Inbound">
<file:filename-wildcard-filter
pattern="Associate_Travel_Details.xml" />
</file:inbound-endpoint>
<log-component />
<byte-array-to-string-transformer
name="ByteArrayToString" />
<vm:outbound-endpoint ref="A" />
</flow>
<flow name="test">
<composite-source>
<vm:inbound-endpoint ref="A" />
<jdbc:inbound-endpoint
queryKey="SelectAssociateFromTVDB" />
</composite-source>
<all>
<jdbc:outbound-endpoint
queryKey="SelectAssociateFromTVDB.ack" />
<choice>
<when expression="#[map-Payload:[TEST==1]]">
<stdio:outbound-endpoint name="out" system="OUT"
exchange-pattern="one-way" />
</when>
<otherwise>
<file:outbound-endpoint
path="C:\Users\303250\Desktop\Mule\Mule_Integration_PoC\TV" />
</otherwise>
</choice>
</all>
</flow>
</mule>
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
*Mariano Capurro*
Engineering Technical Manager
MuleSoft
25 de mayo 555 9th floor
C.A.B.A., Argentina
Tel: +54 11 5353 4497
Mail: mariano.capurro-569aJbr3hvNWk0Htik3J/***@public.gmane.org
Pablo La Greca
2012-02-15 18:41:16 UTC
Permalink
Hi,

JDBC default exchange pattern is one-way. So If you execute a query with an jdbc outbound endpoint the result will not be considered.

Change this endpoint:

<jdbc:outbound-endpoint queryKey="SelectAssociateFromTVDB.ack" />

Add exchange-pattern="request-response".

HTH, Pablo.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Harish S
2012-02-17 05:30:50 UTC
Permalink
Hi guys,

I want to know whether i have used the correct expression for the condition check or not. I have a doubt on that expression. If its wrong then correct me.

<when expression="#[map-Payload:TEST==1]"> is the one i am using. we can see that in the main code which is der in the previous posts.

Thanks and regards,
Harish

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Daniel Feist
2012-02-17 11:36:31 UTC
Permalink
Hi,

"map-payload" should be lower case.

Anyhow this expression evaluator won't let you compare the value with a literal, confusing I know :-( For this you'll need to use the groovy expression evaluator ...

<when expression="#[groovy:payload['TEST'] == 1]">

Dan
Post by Harish S
Hi guys,
I want to know whether i have used the correct expression for the condition check or not. I have a doubt on that expression. If its wrong then correct me.
<when expression="#[map-Payload:TEST==1]"> is the one i am using. we can see that in the main code which is der in the previous posts.
Thanks and regards,
Harish
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...