Reputation: 760
The data type returned by the Mule enricher when wrapped display very strange behaviour. It returns a ResultSetIterator in some situations and List at other times. I have the exact same configuration in a flow being the only difference i.e. here it is a sub-flow. Does the return type behave differently when the database component in an enricher is in a subflow than if in a flow?
<sub-flow name="process.customer">
<enricher target="#[variable:customers]"
doc:name="Customer Enrichment">
<db:select config-ref="MySQLConfig"
doc:name="Customer Query"
fetchSize="3000" streaming="true">
<db:parameterized-query><![CDATA[
SELECT * FROM CUSTOMER WHERE STATUS='ACTIVE'
]]></db:parameterized-query>
</db:select>
</enricher>
<custom-transformer class="com.gdc.transformer.CustomerTransformer" />
<vm:outbound-endpoint exchange-pattern="one-way"
public class CustomerTransformer extends AabstractMessageTransformer{
@Override
public Object transformMessage(MuleMessage message, String
outputEncoding) throws TransformerException {
//Throws ClassCastException i.e. cannot cast ResultSetIterator to
// LinkedList
List<Map<String,Object>> r=
message.getInvocationProperty("customers"));
....
}
}
Upvotes: 0
Views: 241
Reputation: 175
Breen,
If you want your output as List if Maps then disable Streaming=false
else you need your output as iterable object then make the attribute as true.
Upvotes: 0
Reputation: 453
When using streaming="true" on the db:select component, you will get a ResultSetIterator. In this case you also have fetchSize="3000", so it will attempt to select 3000 records at a time. With streaming="false", you will get a List with all of the applicable records loaded in one go.
Upvotes: 0