2
votes

After upgrading to latest SQS connector previously working code now fails.

  • Mule ESB and Integration Platform Version: 3.6.0 Build: ed775fdb
  • Amazon SQS Connector (Mule 3.5.0+) 3.0.0.201506091134

The latest version of the connector requires the message attribute to be specified.

API doc's show message should be a String. http://mulesoft.github.io/sqs-connector/3.0.0/mule/sqs-config.html#send-message

Using:

<object-to-string-transformer doc:name="Object to String"/>

The flow takes the posted data and submits it as a SQS message.

<flow name="rxWebhook">
    <http:listener config-ref="HTTPS_8081" path="/" doc:name="HTTPS" responseStreamingMode="ALWAYS">
        <http:response-builder disablePropertiesAsHeaders="true"/>
    </http:listener>
    <object-to-string-transformer doc:name="Object to String"/>
    <sqs:send-message config-ref="Amazon_SQS_USWEST2" message="#[payload]" queueUrl="${aws.sqs.myQueue}" doc:name="Amazon SQS"/>
</flow>

When posting json data to the flow it errors with:

org.mule.api.transformer.TransformerMessagingException: Failed to transform from "json" to "java.util.HashMap". Message payload is of type: String

1

1 Answers

2
votes

I think it's because theres i an optional parameter named:

<sqs:message-attributes>

Which defaults to #[payload] and expects the payload to be a Map. So to avoid this, specify the param and try passing null maybe:

<sqs:send-message config-ref="Amazon_SQS_USWEST2" message="#[payload]" queueUrl="${aws.sqs.myQueue}" doc:name="Amazon SQS">
            <sqs:message-attributes ref="#[null]"/>
</sqs:send-message>