Logic app connecting to MQ getting message item binary content instead of message item content - azure-logic-apps

our Logic app connects to MQ and polls messages, for one of hte queue, I am seeing message in below format coming in Message item binary content,
{
"$content-type": "application/octet-stream",
"$content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48bnM0aW9uVGV4dD4KICA8L0V4Y2VwdGlvbj4KPC9uczA6UG9saWN5VXBkYXRlPg==" //truncated value
}
How to get value from content in logic app?
Also for other queues message coming in Message item content and able to get text data correctly.

The issue got resolved after conneccting with MS Helpdesk, need to use string(Message item binary content) when reading messages, this will get decoded.

Related

Camel MessageID are different route transformation flow

In my camel application, I am trying to send a message from the source AMQ Queue (INLET) doing some TRANSFORMATION(XMLTO JSON) to Target AMQ Queue (OUTLET) The message is successfully transferred from INLET to OUTLET. But the 1st Messages ID is different and the remaining all are the same in the entire route flow.
Below is the Message-IDs :
Message ID :ID:dbf0f290-c7e2-11ec-b776-6eb51c0a3021:-1:-1:-1:-1 (DIFFERENT)
Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME)
Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME)
Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME)
Anyone help me on this.
Before I used exchange.getIn().getMessageId()
After using this exchange.getExchangeId() //Solved my issue

Discord.js V13 -- Store persisting hidden data on the message object

I have coded a bot to send a message response to a given command, !a. I want to store additional data on the message object, so that if the user reacts to that message the bot can read the hidden data property and know the original message resulted from !a.
Ideas I had:
Create a custom property on the message object: Message.Custom_Prop
Hijack an unused property: Maybe Message.webhookId?
Store hidden text in the form of an embed or message content.
I haven't been able to get any of these to work though.
The best way that I can think of is to store an array of message IDs that were triggered by !a. Something like this:
// At the start of your script
const commandResponses = [];
// Logic for sending the command response
message.channel.send("response here").then(msg => commandResponses.push(msg.id));
// Checking whether the message was a response
if (commandResponses.includes(reaction.message.id)) {
// It's a response so do stuff here
}
(Not tested so it's possible that this won't work)

How to transalte messages that comes from server in react native app

I'm building a react-native app with spanish as default language, the problem is that I'm using a open source backend service to serve data and this data comes is in english by default. What I want is to transalate this data/messages that comes from server in my react-native app to show to the user the messages in spanish not in english.
This is the first time I am doing this process and it is not clear to me what are the steps or the flow that is generally followed for this kind of proces(translate messages that comes from server in my app).
You have many approaches to such a thing one comes to mind is
Catch the error/api response message which mostly server error messages comes in codes and messages.
set a condition statement if code equal 2 that means the server is down for example
Example:
You made a request to the server and there was an error with the server let say wrong username and password, now the server returns a message and a error code you have to get the code or the message and show your own message
.....made the request the server returned
{ code: 192, message: Wrong username/Password }
now in your code you will do the following
if(code == 192){
...do your message
}
P.S this is just on top my head since you didn't share any codes or responses from your server.
UPDATE :
If you want to translate all your strings/messages that comes from the server you would need to do another approche something like this
Create a file contain all the strings/codes from the server
compare messages/code comes from the server and the file will return the text you want
{ "102": "Hola", "103": "Bien", "104": "Nada", "105": "Si", }
now this file contain the error/message code all you have to do is when you receive the code grab the message from this file
let translation = {
"101": "Hola",
"102":"Si"
};
translation["102"]; // Result will be Si
Now this is the most accurate approach but you have to know all the messages/codes comes from the server, now if you want something to translate on the fly you might wanna use translation library and may not be accurate translation

Get the previous message to a discord channel

Given a discord message id and a channel id, is there a way of finding the previous message to the same discord channel?
Message ids are intigers, and my impression is that the are monotonously increasing. So if there was a way of looking up all the message ids that a channel has recieved, i think it would be as simple as finding the highest that is less than the id you are interested in.
Im not sure if u meant to find the content of the message itself or the previous message before it but you can read more on txt_channel.history here:
What history does is enabling you to see the message history of a text channel.
So if you want to find the contents of a specific message using it's id you can do:
(of course you need to fetch the text channel, you can look at here)
async for msg in txt_ch.history(limit=[how many messages back you want the loop to go]):
if msg.id == ID_OF_MSG: # you found the message
print("the message with the id has been found")
now this code ^^ is pointing you to the message you gave with the current id but if you want to get the message previous to it you just add this:
async for msg in txt_ch.history(limit=[how many messages back you want the loop to go]):
found_message = False
if msg.id == ID_OF_MSG: # you found the message
found_message =True
elif found_message:
found_message = False
print("previous message")
Of course you can change the last line on the print to something like:
print(msg.content)
to see it's content, or you can send it back to the channel, it is up to you.
side not:
I tried to test it and it doesn't seem that the ids of the messages are one after another so you can't do id-1 to get the previous message id.

Data not transferring from one endpoint to another endpoint with camel

I'm requesting to https://xx.xx.x.xxx/consumers/ domain and I'm getting some response data as JSON format, and I'm passing it another endpoint direct:consumer, but in direct:consumer endpoint if print body I'm getting empty, could anyone help me how to transfer the data from one endpoint to another endpoint.
from("timer://runOnce?repeatCount=1")
.process(consumerCreate)
.to("https://xx.xx.x.xxx/consumers/").log("response data from create:: ${body}")
.to("direct:consumer");
In the below endpoint, if print the body getting an empty response, not getting JSON data
from("direct:consumer").log("the body is ${body} ");
Can anyone please help me is it expected behaviour or am I missing something?
Take a look at enabling steam caching:
https://camel.apache.org/manual/latest/stream-caching.html
Without it, the stream returned by http producer can only be read once, e.g in the first log message. Hence why nothing is printed in the second direct:consumer route when it comes to log the message body.

Resources