Good day all,
i am finding a difficulty on publishing messages using node js code through an API gateway POST to SNS using the filtering policy (message attributes) which is set to service_type in SQS and SNS
so the messgae should be sent to a specific queue based on the filter i am having, my current set up is as follows
mapping template
Action=Publish##
&TopicArn=$util.urlEncode('arn:....fifo')##
&Message=$util.urlEncode($input.json('$.Message'))##
&Subject=$util.urlEncode($input.json('$.Subject'))##
&MessageAttributes.member.1.Name=service_type##
&MessageAttributes.member.1.Value.DataType=String##
&MessageAttributes.member.1.Value.StringValue=$util.escapeJavaScript($input.json('$.ServiceTypeValue'))##
URL Query String Parameters
MessageAttribute.entry.1.Name 'service_type'
MessageAttributes.entry.1.Value.DataType 'String'
MessageAttributes.entry.1.Value.StringValue 'order'
node js code
const axios = require('axios');
let url = `apiurl`;
//let message_attribute ={ message_attribute:'order'};
let payload = {
message: 'First Message',
MessageAttributes: {
service_type: {
DataType: 'String',
StringValue: 'order',
BinaryValue: null
}
}
};
axios
.post(url, payload)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
your help would be much appreciated