mule database iterating data and mapping - mule

I am trying to fetch data from db, do mapping and upload to cloud for each record from db one by one. I have done below approach:
select data from db, map each record from the db, then upload.
Mule flow:
<flow name="psi2sfdcFlow2" doc:name="psi2sfdcFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="psi2sfdc" doc:name="HTTP"/>
<flow-ref name="psi-update-Reading" doc:name="Flow Reference"/>
<db:select config-ref="PostgreSQL" doc:name="PSI-Select">
<db:parameterized-query><![CDATA[SELECT * FROM clients_int WHERE int_status = 'Reading']]></db:parameterized-query>
</db:select>
<object-to-string-transformer returnClass="java.lang.Object" doc:name="Object to String"/>
<foreach doc:name="For Each">
<invoke name="db2sfdcmapping" object-ref="createAccount" method="getPayloadData" methodArguments="#[message.payload]" doc:name="Invoke"/>
<logger message="===Uplaod each row from db to cloud==== " level="INFO" doc:name="Logger"/>
</foreach>
</flow>
Error:
ERROR 2015-06-17 14:24:56,735 [[psi2sfdc].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException). Message payload is of type: String
Type : org.mule.api.MessagingException
Code : MULE_ERROR--2
Payload : [{phone=772-567-7461, pr_specialist_email=null, sic_code=5211, status=ACTIVE, address1=722 THIRD PLACE, fax=772-567-5054, naics_code=null, client_id=1630, bus_name=HBS INC, address2=null, contact=JANIE LUE, bus_name2=null, country=USA, termination_date=null, state=FL, zip=32962, client_fed_ids={59-1457513}, last_pay_date=2009-11-06, city=VERO BEACH, int_status=Reading}, {phone=713-668-9484, pr_specialist_email=null, sic_code=3714, status=DNE, address1=1140 AVE S, fax=null, naics_code=null, client_id=172, bus_name=FRANK'S SUPPLY OF DALLAS, address2=null, contact=PAM DEL BELLO, bus_name2=null, country=USA, termination_date=null, state=TX, zip=75050, client_fed_ids=null, last_pay_date=null, city=GRAND PRARIE, int_status=Reading}, {phone=(910)854-5000, pr_specialist_email=null, sic_code=null, status=DNE, address1=2720 IMMANUEL ROAD, fax=(910)854-0020, naics_code=null, client_id=2693, bus_name=SCIULLO INTERIOR SYSTEMS, address2=null, contact=Frank Sciullo, bus_name2=null, country=USA, te...
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
org.mule.util.collection.EventToMessageSequenceSplittingStrategy:57 (null)
2. Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException). Message payload is of type: String (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.lang.IllegalArgumentException: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}"
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:57)
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:22)
at org.mule.routing.CollectionSplitter.splitMessageIntoSequence(CollectionSplitter.java:29)
at org.mule.routing.Foreach$CollectionMapSplitter.splitMessageIntoSequence(Foreach.java:245)
at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:56)
Java file:
public class Db2sfdc {
public List<Map<String, Object>> getPayloadData(#Payload String src){
System.out.println("Src-->"+src);
Map<String, Object> sfdcFields = new HashMap<String, Object>();
List<Map<String, Object>> accountList = new ArrayList<Map<String,Object>>();
sfdcFields.put("ID", "001m000000In0p5AAB");
sfdcFields.put("Current_WSE_Count__c", "20");
accountList.add(sfdcFields);
return accountList ;
}
}
Question:
1)Do I need to use object-to-string-transformer to get the data from db and map in java component?
2) How do I upload/send the data each row from db. When i use for each i am getting above error since I have converted db data to string transformer. I am using java component to transform instead of Data Mapper.
EDIT:
After removing object to string transformer, getting following error at the end, i.e after java mapping:
ERROR 2015-06-17 15:02:09,954 [[psi2sfdc].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : java.io.NotSerializableException: org.postgresql.jdbc4.Jdbc4Array (org.apache.commons.lang.SerializationException). Message payload is of type: HttpResponse
Type : org.mule.execution.ResponseDispatchException
Code : MULE_ERROR--2
Payload : org.mule.transport.http.HttpResponse#65b9ccef
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/execution/ResponseDispatchException.html
********************************************************************************
Exception stack is:
1. org.postgresql.jdbc4.Jdbc4Array (java.io.NotSerializableException)
java.io.ObjectOutputStream:1183 (null)
2. java.io.NotSerializableException: org.postgresql.jdbc4.Jdbc4Array (org.apache.commons.lang.SerializationException)
org.apache.commons.lang.SerializationUtils:111 (null)
3. java.io.NotSerializableException: org.postgresql.jdbc4.Jdbc4Array (org.apache.commons.lang.SerializationException). Message payload is of type: HttpResponse (org.mule.execution.ResponseDispatchException)
org.mule.transport.http.HttpMessageProcessTemplate:139 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/execution/ResponseDispatchException.html)
********************************************************************************
Root Exception stack trace:
java.io.NotSerializableException: org.postgresql.jdbc4.Jdbc4Array
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.commons.collections.map.AbstractHashedMap.doWriteObject(AbstractHashedMap.java:1182)
at org.mule.util.CaseInsensitiveHashMap.writeObject(CaseInsensitiveHashMap.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
**
EDIT:2
Solved, after below changes:I have converted to json object after select query as:
<db:select config-ref="PostgreSQL" doc:name="PSI-Select">
<db:parameterized-query><![CDATA[SELECT * FROM clients_int WHERE int_status = 'Reading']]></db:parameterized-query>
</db:select>
<foreach doc:name="For Each">
<json:object-to-json-transformer returnClass="java.lang.Object" doc:name="Object to JSON"/>
<logger message="===Main Flow #[payload]===" level="INFO" doc:name="Logger"/>
</foreach>

Remove the object-to-string-transformer: it transforms the rows enumeration into a String, which prevents for-each to work.
EDIT: Moreover, because the inbound HTTP endpoint is request-response, it will need to return a response to the client. Mule will use the current payload (a Jdbc4Array instance) as the payload of the HTTP response and will fail.
You need to add a set-payload to set the body of the HTTP response to whatever you want to return to the caller. Use an http:response-builder to set response headers, cache directives... as well.
Alternatively, you can switch the HTTP inbound endpoint to one-way. This will return OK to the client immediately, and whether what happens down the flow succeeds or fails.

Related

Mule ESB: Read a binary file and create attachment in Salesforce

I'm developing an integration using Mule ESB which needs to read a binary file (.zip) from the file system and create it as an attachment in Salesforce. However, I'm not able to get this work and I'm getting the following error:
INFO 2016-03-11 13:55:47,338 [[sfdc].File.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: /Users/aaa/Desktop/temp/files/test.zip
INFO 2016-03-11 13:55:47,345 [[sfdc].sfdcFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Payload = org.mule.transport.file.ReceiverFileInputStream#4f0870aa
INFO 2016-03-11 13:55:47,348 [[sfdc].sfdcFlow.stage1.02] com.mulesoft.weave.mule.utils.MuleWeaveFactory$: MimeType was not resolved 'application/zip' delegating to Java.
ERROR 2016-03-11 13:55:47,367 [[sfdc].sfdcFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : Could not find a transformer to transform "SimpleDataType{type=java.util.LinkedHashMap, mimeType='*/*', encoding='null'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}".
Type : org.mule.api.transformer.TransformerException
Code : MULE_ERROR-236
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html
Exception stack is:
1. Could not find a transformer to transform "SimpleDataType{type=java.util.LinkedHashMap, mimeType='*/*', encoding='null'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}". (org.mule.api.transformer.TransformerException)
org.mule.registry.MuleRegistryHelper:248 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
Root Exception stack trace:
org.mule.api.transformer.TransformerException: Could not find a transformer to transform "SimpleDataType{type=java.util.LinkedHashMap, mimeType='*/*', encoding='null'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}".
Here is the configuration file.
<sfdc:config name="Salesforce__Basic_Authentication" username="test#test.com.staging" password="password" securityToken="token" url="https://test.salesforce.com/services/Soap/u/34.0" doc:name="Salesforce: Basic Authentication"/>
<file:connector name="File" readFromDirectory="/Users/aaa/Desktop/temp/files" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="sfdcFlow">
<file:inbound-endpoint path="/Users/aaa/Desktop/temp/files" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<logger message="Payload = #[payload]" level="INFO" doc:name="Logger"/>
<object-to-byte-array-transformer doc:name="Object to Byte Array"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
ParentId: "b2U7A0B01054OyZ",
Name: "Test Name",
Description: "Test Descr",
Body: payload
}]]></dw:set-payload>
</dw:transform-message>
<sfdc:create config-ref="Salesforce__Basic_Authentication" type="Attachment" doc:name="Salesforce" />
</flow>
I checked the Anypoint exchange and googled, but all the pointers that I'm getting is geared towards text files (like CSVs). Appreciate if someone can share a working example to read a binary file and create it as an attachment in Salesforce (can attach to any object like case object).
I'm using Anypoint Studio 5.4.1 with Mule runtime 3.7.3 EE.
Edit: I was able to resolve the issue. Basically, as #david said, the create method takes a collection and I was not passing it as a collection. Here is the updated code (just the dataweave part):
[
{
ParentId: "b2U7AB010540yZ",
Name: "Test Name",
Description: "Test Descr",
Body: payload
}
]
Note the open and close square brackets. Thanks #david.
What I understand from the SFDC Connector doc, is that the create method expects a collection of objects.
But you're passing a map to it, thus this exception:
Could not find a transformer to transform "SimpleDataType{type=java.util.LinkedHashMap, mimeType='*/*', encoding='null'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}"
Try adding the map you create in dw:transform-message to a list, using a transformer for this, and it should work.

Error sending HTTP request. Message payload is of type: LinkedHashMap [MULE ESB]

I'm new in MULE ESB, I have this code and i'm trying sending a http request using http:request with the following format:
"http: //www.host.com/api/commentThreads?key=val&part=val2&..."
<file:inbound-endpoint connector-ref="fileConnector" path="C:/tmp/input"
doc:name="Reader File Configuration" responseTimeout="10000"
encoding="UTF-8" mimeType="text/plain"
pollingFrequency="20000">
<file:filename-wildcard-filter pattern="*.json"/>
</file:inbound-endpoint>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<logger level="INFO" message="#[payload]" doc:name="Logger" />
<http:request config-ref="HTTP_Request_Configuration" path="/commentThreads" method="GET" port="443" doc:name="HTTP Request">
<http:request-builder>
<http:query-param paramName="key" value="#[message.payload.key]"/>
<http:query-param paramName="allThreadsRelatedToChannelId" value="#[message.payload.allThreadsRelatedToChannelId]"/>
<http:query-param paramName="part" value="#[message.payload.part]"/>
</http:request-builder>
</http:request>
But I'm having this error:
Message : Error sendinbut g HTTP request. Message payload is of type: LinkedHashMap
Code : MULE_ERROR--2
Exception stack is:
null (java.util.concurrent.TimeoutException) org.glassfish.grizzly.impl.SafeFutureImpl$Sync:357 (null)
Error sending HTTP request. Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.http.internal.request.DefaultHttpRequester:190
(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
The question is how can I do to make a http request with that format using the map?
According to documents
https://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector#HTTPRequestConnector-HTTPRequestBody
The Mule Message payload is converted into a byte array and sent as
the HTTP Request's body. This behavior is carried out always, except
in the following scenarios:
The Mule Message's Payload is a Map of keys and values
Generate the Request Body with
Content-Type:application/x-form-urlencoded
Whenever the message payload is a Map, the connector automatically
generates an HTTP request with the header
Content-Type:application/x-www-form-urlencoded. The keys and values of
the map in the payload are converted into form parameter keys and
values in the body of the HTTP request.
I suppose the map is converter automatically for the request. Correct me if I'm wrong
It was necessary to make a transformation before the
<json: json-to-object-transformer returnClass = "java.util.Map" doc: name = "JSON to Object" />
It is corrected by putting
<byte-array-to-string-transformer doc: name = "Byte Array to String" />
The error you're getting actually is not because your request has something wrong (or at least is not failing at that stage) but that your app is not being able to connect to the http server you're trying to send the request to. You can infer this by the exception you're getting java.util.concurrent.TimeoutException.
In order to troubleshoot please verify the host name and port are typed correctly.

Not able to access Jira Payload in JAVA (java.util.Arrays$ArrayList)

Here is my Flow information. Trying to GET one issue from JIRA and want to setup that issueID to another project. Here i want to use Custom Transformer and setup all objects using JAVA coding.
<jira:config name="Jira" connectionUser="XXXXXXX" connectionPassword="XXXXX" connectionAddress="http://XXXXXXX/rpc/soap/jirasoapservice-v2" doc:name="Jira">
<jira:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
<reconnect count="3"/>
</jira:config>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="jira-pocFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/input" doc:name="HTTP"/>
<jira:get-issues-from-jql-search config-ref="Jira" jqlSearch="id=MRT-75" maxNumResults="100" doc:name="Jira"/>
<set-variable variableName="payload" value="#[payload[0]]" doc:name="Variable"/>
<component class="JIRATransformer" doc:name="Java"/>
<jira:create-issue-using-object config-ref="Jira" doc:name="Jira" >
<jira:issue ref="#[message.payload]"/>
</jira:create-issue-using-object>
<logger level="INFO" doc:name="Logger"/>
</flow>
I am trying to access JIRA payload object but it's throwing me Error as Type Cast Exception.
#Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws org.mule.api.transformer.TransformerException {
ArrayList<com.atlassian.jira.rpc.soap.beans.RemoteIssue> list = new ArrayList(Arrays.asList(message.getPayload()));
for(RemoteIssue q : (List<RemoteIssue>) list){
System.out.println("Print AssigneeInfo:->"+q.getAssignee());
}
}
I am getting following Errors.
ERROR 2015-04-15 19:58:59,526 [[jira-poc].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Component that caused exception is: DefaultJavaComponent{jira-pocFlow.component.887693985}. Message payload is of type: Arrays$ArrayList
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. java.util.Arrays$ArrayList cannot be cast to com.atlassian.jira.rpc.soap.beans.RemoteIssue (java.lang.ClassCastException)
JIRATransformer:29 (null)
2. Component that caused exception is: DefaultJavaComponent{jira-pocFlow.component.887693985}. Message payload is of type: Arrays$ArrayList (org.mule.component.ComponentException)
org.mule.component.DefaultComponentLifecycleAdapter:348 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to com.atlassian.jira.rpc.soap.beans.RemoteIssue
at JIRATransformer.transformMessage(JIRATransformer.java:29)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:141)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:69)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
I tried to follow this Documentation URL but couldn't able to figure it out.
http://mulesoft.github.io/jira-connector/java/com/atlassian/jira/rpc/soap/beans/RemoteIssue.html
I want to Access this Payload and want to update some details from payload object here. I can access payload using MEL expression #[payload[0]] and it automatically coverts it to com.atlassian.jira.rpc.soap.beans.RemoteIssue but using Java code i am not able to type cast it.
Can you please help me to cast this object correctly so i can access the Payload here ?
Thanks.
There's a bug in your component.
This Arrays.asList(message.getPayload()) wraps the message payload into a list. But the message payload is already a List<RemoteIssues> so this wrapping is unnecessary.
If you look at the source code of the JIRA connector, you'll see that MuleSoft prefers late casting of the RemoteIssue. I suggest you do the same:
for (Object o : ((List) message.getPayload())) {
RemoteIssue ri = (RemoteIssue) o;
...
}

facing error Object "java.lang.String" not of correct type in mule esb

I am trying to download ftp file on my local drive. I amfacing following error
Message : Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
Code : MULE_ERROR--2
I used batch processing. below is my flow.
Batch Processing Input flow http(One way) then in Processing record phase i used java component which is bind with my class. I wrote one function which will download my file from ftp server. My method is return void with no argument
<batch:job name="filetosalesBatch1">
<batch:input>
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8088" doc:name="HTTP" path="test"/>
<component doc:name="Java" class="com.ReadFile">
<no-arguments-entry-point-resolver>
<include-entry-point method="ftpDownloadFile"/>
</no-arguments-entry-point-resolver>
</component>
</batch:input>
<batch:process-records>
<batch:step name="Batch_Step">
<logger level="INFO" doc:name="Logger"/>
</batch:step>
</batch:process-records>
<batch:on-complete>
<logger level="INFO" doc:name="Logger"/>
</batch:on-complete>
</batch:job>
below is my method
public void ftpDownloadFile()
{
// logic for downloading file
}
When I eun my mule application got following error
Message : Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
How to solve this error please help me
Thanks
Please try to replace your ftpDownloadFile method by this
public List<String> ftpDownloadFile() {
return Arrays.asList("A","B","C","D","E","F","G");
}
What it is wrong in your flow? It is because the last payload is an String (request sent by http). In your method you should return a Collection and that would be the payload for the batch:process-records
You should not use a custom component for downloading a file. You can use the FTP component to retrieve the file contents and transform the content to a List so batch would able to process it.

Scatter gather routing error. Message payload is of type: String

I'm new to Mule and while working on a fairly simple Hello World example on Anypoint Studio to test out the Scatter/Gather flow control element, I'm getting the following error, without much else in the way of information:
ERROR 2014-12-19 22:00:30,172 [[unifinesb].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Exception was found for route(s): 0. Message payload is of type: String
Type : org.mule.routing.CompositeRoutingException
Code : MULE_ERROR--2
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/routing/CompositeRoutingException.html
Payload : /Waldo
********************************************************************************
Exception stack is:
1. Exception was found for route(s): 0. Message payload is of type: String (org.mule.routing.CompositeRoutingException)
org.mule.routing.CollectAllAggregationStrategy:51 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/routing/CompositeRoutingException.html)
********************************************************************************
Root Exception stack trace:
org.mule.routing.CompositeRoutingException: Exception was found for route(s): 0. Message payload is of type: String
at org.mule.routing.CollectAllAggregationStrategy.aggregateWithFailedRoutes(CollectAllAggregationStrategy.java:51)
at org.mule.routing.CollectAllAggregationStrategy.aggregate(CollectAllAggregationStrategy.java:38)
at org.mule.routing.ScatterGatherRouter.processResponses(ScatterGatherRouter.java:207)
at org.mule.routing.ScatterGatherRouter.process(ScatterGatherRouter.java:135)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at ...
Judging from the top description of the error, I understand the problem to be that Scatter gather does not receive String payloads, even though the current documentation for the component mentions nothing of the sort. Is this correct?
The flow I'm running is fairly simple, receiving a String from an inbound http and trying to route it to a REST service that will use the String to print something (returning text/plain) and to a DB to store the String in a table. Relevant code follows:
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" doc:name="HTTP"/>
<expression-filter expression="#[payload != '/favicon.ico']" doc:name="Filter browser icon padding"/>
<logger message="current payload is #[payload]" level="INFO" doc:name="Startup log - to stdout"/>
<scatter-gather doc:name="Scatter-Gather">
<processor-chain>
<logger message="#['Rest branch msg input :' + payload]" level="DEBUG" doc:name="File Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/application/rest/mensaje?givenName=#[payload]" doc:name="REST Service"/>
<logger message="#['Rest msg output :' + payload]" level="DEBUG" doc:name="File Logger"/>
</processor-chain>
<processor-chain>
<logger message="#['Database msg input :' + payload]" level="DEBUG" doc:name="File Logger"/>
<db:insert config-ref="MySQL_VestaLocal" doc:name="Application Postgress">
<db:parameterized-query><![CDATA[insert into http_user_info (first_name) values ('#[payload]');]]></db:parameterized-query>
</db:insert>
<logger message="#['Database msg output :' + payload]" level="DEBUG" doc:name="File Logger"/>
</processor-chain>
</scatter-gather>
<set-payload value="#['REST DB Success!']" doc:name="Set Payload"/>
Trawling through the net I found this old Mule JIRA issue with an exception similar to what I'm getting, but trying out the suggested solution (workaround?) didn't do anything for me: https://www.mulesoft.org/jira/browse/MULE-7594
Something wrong is happening in your route 0.
You are getting a composite routing exception as per documentation:
The CompositeRoutingException is new to the 3.5.0 Runtime. It extends
the Mule MessagingException to aggregate exceptions from different
routes in the context of a single message router. Exceptions are
correlated to each route through a sequential ID.
This exception exposes two methods which allow you to obtain the IDs
of failed routes and the exceptions returned by each route.
The getExceptions method returns a map where the key is an integer
that identifies the index of the failed route, and the value is the
exception itself. The getExceptionForRouteIndex(int) method returns
the exception of the requested route ID.
As you don't have an execption strategy, the toString is call to that exception and that only prints the route failing (that has nothing to do with the fact that the payload is String)
Please use the following exeption strategy to find out exactly what's wrong:
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="ERROR" message="#[exception.exceptions]"/>
</catch-exception-strategy>