Mulesoft Attribute Returning Null sqs.message.receipt.handle - mule

I apologize if this is a dumb question, but I couldn't find much documentation.
I have a Receive Messages component for receiving an SQS Message, and I'm attempting to retrieve an attribute value for a downstream operation.
If I retrieve an attribute such as ApproximateReceiveCount with #[attributes.SenderId] everything works as expected.
But, if I attempt to get sqs.message.receipt.handle with #[attributes.sqs.message.receipt.handle] it returns null. Running in debug, I can see that there is a value for sqs.message.receipt.handle
Is there something special I need to do with attributes that have multiple .? What would the term be for this type of attribute for further research?

If the dots are part of the key then try:
#[ attributes["sqs.message.receipt.handle"] ]
or
#[ attributes.`sqs.message.receipt.handle` ]

Related

watson conversation check entity exists

I want to check if an entity is part of the users input.
Example:
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
As you can see by this example, the value of the entity#PRODUKT_INTENT_STOP_LIST
is a variable. I put this at a condition for a node, but this is not working.
If I use a hardcoded string instead of the variable it is working fine.
entities['#PRODUKT_INTENT_STOP_LIST']?.contains('Chart') works fine
but setting $variables.tmpEntity to 'Chart' a and then ask for
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
is not working.
Can someone tells me what's wrong here?
Still trying to understand what you are trying to do.But if you want to check whether an entity exist in your input or not you can do it by applying condition on size of that entity.
"context":{
"size":"<?#Entity.size()?>"
}
now if size is equals to 0 then entity does not exist.
I know this is a longer way but it also tells you how many times does that entity exist in your input.
Hi I used the wrong statement.
This statement should work:
entities[PRODUKT_INTENT_STOP_LIST]?.get($variables.countEntity).value==$variables.$variables.tmpEntity
$variables.countEntity : counter to iterate thru entity array #PRODUKT_INTENT_STOP_LIST to check if an entity value is equal $variables.tmpEntity
Regards

Endpoints returning BufferInputStream with strange value in Mulesoft Anypoint Studio

I have 3 separate APIs, A, B, and C. A and B are completely independent, whereas C queries A and B to compile data together. Each API is in its own project and running on its own port (8081, 8082, and 8083, respectively).
I am able to successfully hit A and B individually AND through C...sort of. When C hits one of these endpoints, the result comes back as a glassfish.grizzlly.utils.BufferInputStream.
I've dealt with this BufferInputStream type before by using a Transform Message Component. However, doing so here simply produces an error, saying that payload.id is of the wrong type (it should be an integer). When running this in debug mode, I can see that A has an Output Payload with id: Integer (it is of a custom type). However, upon moving back into C's flow, the payload is now the aforementioned BufferInputStream type, and I'm unable to directly access payload.id.
In short: How do I retrieve data in one project from another project?
Thanks in advance!
Update:
I used an Object to String transformer on the BufferInputStream to get a better look at the value. It appears to be in the format of a URL:
id=12345&name=nameValue&otherVal=%5B8499%5D...
I can #[payload.split('&')] at this point and get most of what I need, but then there's still the issue of things like the following:
summary=Words+with+plus+signs+in+the+middle
Again, I can work around this with things like split, but surely this is not what is intended.
Update 2:
I discovered the following warning:
[[test].api-httpListenerConfig.worker.01]
org.mule.module.http.internal.listener.HttpResponseBuilder:
Payload is a Map which will be used to generate an url encoded http body but
Contenty-Type specified is application/java; charset=windows-1252 and not
application/x-www-form-urlencoded
I'm not entirely sure what to do with that info, though the Contenty-Type typo is interesting ^^
Solved! In A and B, I needed to use an Object to Byte Array transformer before returning the value. This allows me to use a Byte Array to Object transformer in C and get the original value back.

What is the simplest way to completely replace an assertion message using FA (and nunit)?

For example;
results.Errors.Count.Should().Be(0, $"because {results.Errors[0]}");
produces the Result Message:
Expected value to be 0 because 'Name' should not be empty., but found 2.
But what I really want, in this particular instance (invocation of the assertion) is just the value of results.Errors[0], that is I would like the message to be just: 'Name' should not be empty.
(As an aside what I really want is to pass a concatenated string representation of the entire results.Errors array, but my linq/lambda skills aren't there yet)!
So how can I get FA to just use what I supply as the message string?
You can't do that. The because part is baked into the language to promote failure messages that are as natural as possible.

ESB mule : differences in notation

imagine a very simple flow with a HTTP inbound and a body-to-parameter-map. Payload contains something like {prop1=aaa, prop2=eee, prop3=iii}.
My question is, why if I try to access #[payload.prop1] sometimes (and I said sometimes) it gets null value, while #[payload['prop1']] seems to be allways correct?
Those are equivalent, the only different would be that the dot notation also support objects while the key one only support collections.
It's perhaps that the you are using the dot notation with keys that already contain a dot? Like http.status. In those cases you should either escape with 'http.status'.

Is a RESTful PUT with no data "kosher," or should a DELETE always be used?

I have a RESTful route that works on an array field of a resource, such:
PUT /:id/mylist
When I do a PUT, I throw an error if the input is empty. That is, if an empty array is passed. I require at least one element in the array. So if the resource has an array of nine elements, and the route is called to PUT three, those three replace the existing nine.
But you cannot pass in no elements, because that would erase the nine and leave nothing.
Having no element IS ALLOWED, however - it just seems to me that allowing the array to be "cleared" in a PUT is wrong, and that it should only be done thusly:
DELETE /:id/mylist
Am I wrong? Are both okay? Is one preferred over the other?
I would think that doing DELETE on a list resource would infer that the list is no longer there and future GET requests to the URL would return a 404.
However, doing a PUT with an empty list would cause future GET requests to return a 200 and an empty list (however that is represented).
I would say both are valid approaches, it just depends one what are the most natural semantics for the resource.