I am sending an MQ message and getting a messageID and correlationID back in return as expected, and I can capture the response from specific message that I send using the messageID returned by the MQ server.
I put my application into a load testing tool and I saw that in some cases the messageID returned by the queue manager was the same as a previous message, and in these cases the app failed to read the next message with the same messageID.
I'm not the owner of the queue manager and the response from the admin was "created your own message id".
Can I do that? Does the messageID need to have a specific format?
This is my code :
message = strInputMsg;
queueMessage = new MQMessage();
queueMessage.WriteString(message);
queueMessage.Format = MQC.MQFMT_STRING;
queueMessage.Expiry = timeOutExpiry;
queueMessage.ReplyToQueueName = QueueNameExpiry;
queuePutMessageOptions = new MQPutMessageOptions();
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;
queue.Put(queueMessage, queuePutMessageOptions);
bytReturn = queueMessage.MessageId;
So can I set the MessageID property to my own message ID value before I send the message, like the below?
queueMessage.MessageId = myOwnMessageId
Yes, it's possible that the code sets the message ID explicitly but your code appears to not reuse the MQMD structure which is how that normally happens. It is more likely based on your description and code provided that the load testing tool is replaying the same messages multiple times and preserving the Message ID while doing so.
If MQ is allowed to set the Message ID it guarantees this to be unique within the queue manager for IDs that it generates. It does not guarantee a GUID across many queue managers but does attempt to ensure no collisions by including 12 characters of the QMgr name in the Message ID. So although we have no information as to which load testing tool is being used and if it employs message replay, that possibility seems much more likely than that MQ has a bug that duplicates message IDs during execution of the .Net MQMessage() class constructor.
Please see:
MQMessage.NET class which says "Creates an MQMessage object with default message descriptor information..." Of course, the default MQMD causes the QMgr to generate the Message ID.
MQMD - MsgId (MQBYTE24) which explains in a note at the bottom how MsgID is made to be unique and in the body how it can be controlled by the application putting the messages.
Related
The application is designed to send messages to a group on messanager. It throws me an error that supposedly group id is not correct even though it is correct. in parameters code will get messages from email to send direcly to group chat:
string groupid = "correctgroupid";
FacebookClient fb = new FacebookClient("correctclient");
foreach (Message message in messages)
{
dynamic parameters = new ExpandoObject();
parameters.message = message.Snippet;
fb.Post("/"+groupid+"/feed", parameters);
}
The program is supposed to be a automatic sender I will add feature to make sure it doesnt send the same emails.
the error that accures:
Facebook.FacebookApiException: „(GraphMethodException - #100) Unsupported post request. Object with ID 'correctid' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api”
For now I have tried to filter the messages based on Message Attribute Name="Class". As you can see in the below code
//Specify attribute list
List<string> AttributesList = new List<string>();
AttributesList.Add("Class");
receiveMessageRequest.MessageAttributeNames = AttributesList;
receiveMessageRequest.QueueUrl = urlSQS;
receiveMessageRequest.MaxNumberOfMessages = 10;
ReceiveMessageResponse receiveMessageResponse = objClient.ReceiveMessage(receiveMessageRequest);
But the messages are not been filtered based on the provided MessageAttributeName = "class".
receiveMessageRequest.MessageAttributeNames = AttributesList;
This tells SQS which message attributes you want it to return with the message if the are present on the message. It is not a message filter. If the attributes aren't present, nothing happens.
But your confusion seems understandable -- it's not actually obvious why the API even has this functionality, though it may be a holdover from when SQS supported only smaller messages than it does today, or it may be so that you can avoid spending any time parsing information from the response that you will end up discarding. I almost always just ask for All.
Please note this regarding messaging services on AWS
SQS : No filtering support ( while picking up messages)
SNS : Supports attributes-based filtering: subscriber can set a subscription attribute (a subscription filter policy) which is applied on incoming messages and only relevant messages can be sent to the subscriber.
EventBridge: Amazon EventBridge supports declarative filtering using event patterns. With event pattern content filtering you can write complex rules that only trigger under very specific conditions. For instance, you might want a rule that will trigger only when a field of the event is within a specific numeric range, if the event comes from a specific IP address, or only if a specific field does not exist in the event JSON.
Please refer my article for a detailed difference between main messaging frameworks on AWS.
https://www.linkedin.com/pulse/mastering-art-decoupling-application-architecture-aws-amit-meena/
It depends on how the message in question gets onto the queue. If you are pushing the message via SNS then yes you can filtered messages; https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html
Any other filtering mechanism doesn't exist right now.
Hope that helps!
As per the AWS SDK method, we can use following code to do the filter.
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest("QUEUE URL" );
receiveMessageRequest.setMaxNumberOfMessages(Integer.valueOf(1));
private static AmazonSQS sqs;
List<Message> messages = sqs.receiveMessage(receiveMessageRequest.withMessageAttributeNames("Attribute Name")).getMessages();
If you want all the message then use given code
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest("QUEUE URL" );
receiveMessageRequest.setMaxNumberOfMessages(Integer.valueOf(1));
private static AmazonSQS sqs;
List<Message> messages = sqs.receiveMessage(receiveMessageRequest.withMessageAttributeNames("All")).getMessages();
I am trying to discover if there is a way to determine the internet message ID after sending an email using the EWS Managed API. I understand you can go in there and get the results from the sent box, but the server that is sending these emails is sending multiple emails at a time from different services.
No you can't, basically because EWS sends message Asynchronously the Id isn't available see https://social.msdn.microsoft.com/Forums/azure/en-US/dd034b8c-ffa1-4ae0-9025-45fcf520c9e5/updateitem-does-not-return-itemid?forum=exchangesvrdevelopment
As a work around you might want to consider setting the Internet messageId on the Message before you send it. As long as it valid and unique it should work okay eg
ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
EmailMessage ema = new EmailMessage(service);
ema.Subject ="test from ews";
ema.Body = new MessageBody("test<br>Rgds<>");
ema.ToRecipients.Add("gscales#domain.com");
ema.SetExtendedProperty(PidTagInternetMessageId,("<" +Guid.NewGuid().ToString() + "#domain.com>"));
ema.SendAndSaveCopy();
Also if you save the message first as a draft before sending it the server will assign the MessageId property which which should then be able to read back using Load.
Cheers
Glen
In C# using NMS API we set Response topic for ActiveMQ in this way
IDestination temp = session.CreateTemporaryTopic();
ITopic consumer = session.CreateConsumer(temp);
And while sending message we set it like this ...
TextMessage reqMessage = session.CreateTextMessage(message);
reqMessage.NMSReplyTo = temp;
How can we do the same thing using Stomp.js?
Most STOMP operations are done using specific headers that are placed in the Message that you send. In this case the 'reply-to' header indicates the address where the receiving client should send its response. So the pattern would be to send the message with the 'reply-to' header set, something like this depending on the library you are using:
stomp.subscribe("/temp-queue/response-queue")
stomp.publish("/queue/work-queue", "WORK", {"reply-to" => "/temp-queue/response-queue"})
Since you are using temp Topic you must ensure that there is subscriber prior to the response message being sent, otherwise it will not get all the replies.
I'm using SMPP client with C# in Vs 2010 to send SMS to SMSC. I just can't figure out how to get the delivery report for the sent messages. I used QuerySM to get the status of the message, but it's returning OK Status even if I send an SMS to the number that is not in use.
Here is my code for getting Delivery Report:
QuerySm deliver = new QuerySm(_MessageID, SrcTon, SrcNpi, SrcAddr);
client.Query(deliver);
It is possible that the SMSC you're using doesn't support query_sm, in this case they may have implemented a placeholder query_sm_resp PDU with a OK status for every request.
You could set the registered_delivery flag in submit_sm to 1 and listen for incoming deliver_sm PDUs, so you get the delivery reports from them, instead of querying them for every message you send.
I solved my problem by using QuerySmResp to get the Delivery Report.
This is the code to check for the Delivery Status of the SMS Message:
QuerySmResp qresp = client.Query(_MessageID, SrcTon, SrcNpi, SrcAddr);
string _Delivery = qresp.MessageState.ToString();
MessageState property will show the status of the message and it's members are:
None
Enroute
Delivered
Expired
Deleted
Undeliverable
Accepted
Unknown
Rejected