MQ Message integer property not updataing - jms

I have a MQ Message. In that, I add an Integer property called "Count" with the value 10. Then I reassign the value to 5 for the same property.But it is not getting updated.
MQMessage message = new MQMessage();
message.writeString("Test Message");
message.setIntProperty("Count", 10);
System.out.println("Count is" + message.getIntProperty("Count")); -->Prints 10
message.setIntProperty("Count",5);
System.out.println("Count is" + message.getIntProperty("Count")); --> Prints 10..But I am expecting 5..

Have you tried putting the message to a queue? If you actually put the message to a queue and get the same message back, you will see that updated value of the property is set in the message i.e. value of "Count" property will be 5, instead of 10.

Related

XMS.NET - Error while sending response back to reply queue/out queue

Regarding: “Sending response back to the out/reply queue.”
There is a requirement to send the response back to a different queue (reply queue).
While sending the response, we have to use the correlation and message id from the request message and pass it to the reply queue as header. I suspect the format of correlation/message id is wrong.
While reading the message, the correlation id and message id format are as below:
MessageId = “ID:616365323063633033343361313165646139306638346264”
CorrelationId = “ID:36626161303030305f322020202020202020202020202020”
While sending the back to out/reply queue, we are passing these ids as below:
ITextMessage txtReplyMessage = sessionOut.CreateTextMessage();
txtReplyMessage.JMSMessageID = “616365323063633033343361313165646139306638346264”;
txtReplyMessage.JMSCorrelationID = “36626161303030305f322020202020202020202020202020”;
txtReplyMessage.Text = sentMessage.Contents;
txtReplyMessage.JMSDeliveryMode = DeliveryMode.NonPersistent;
txtReplyMessage.JMSPriority = sentMessage.Priority;
messagePoducerOut.Send(txtReplyMessage);
Please note:
With the XMS.NET library, we need to pass the correlation and message id in string format as per shown above
With MQ API’s (which we were using earlier) passing the correlation and message ids we use to send in bytes format like below:
MQMessage queueMessage = new MQMessage();
string[] parms = document.name.Split('-');
queueMessage.MessageId = StringToByte(parms[1]);
queueMessage.CorrelationId = StringToByte(parms[2]);
queueMessage.CharacterSet = 1208;
queueMessage.Encoding = MQC.MQENC_NATIVE;
queueMessage.Persistence = 0; // Do not persist the replay message.
queueMessage.Format = "MQSTR ";
queueMessage.WriteString(document.contents);
queueOut.Put(queueMessage);
queueManagerOut.Commit();
Please help to troubleshoot the problem.
Troubleshooting is a bit difficult because you haven’t clearly specified the trouble (is there an exception, or is the message just not be correlated successfully?).
In your code you have missed to add the “ID:” prefix. However, to address the requirements, you should not need to bother too much about what is in this field, because you simply need to copy one value to the other:
txtReplyMessage.JMSCorrelationID = txtRequestMessage.JMSMessageID
A bit unclear what the issue is. Are you able to run the provided examples in the MQ tools/examples? This approach uses tmp queues(AMQ.*) as JMSReplyTo
Start the "server" application first.
Request/Response Client: "SimpleRequestor"
Request/Response Server: "SimpleRequestorServer"
You can find the exmaples at the default install location(win):
"C:\Program Files\IBM\MQ\tools\dotnet\samples\cs\xms\simple\wmq"
The "SimpleMessageSelector" will show how to use the selector pattern.
Note the format on the selector: "JMSCorrelationID = '00010203040506070809'"
IBM MQ SELECTOR

Unable to get proper message Id of message in rocketchat

When i try to send a new message on pressing enter . I am getting message id as "0" when i try to log the message in message.js file . But only for a few messages i am getting id as "0" but database is not showing any entry with message id as "0" .
const {msg} = this;
console.log("tagamsg",msg._id);
id was being set as 0 due to another event that was being called at the same time .

Folder usr coming in the message body

Using IIB 10 and MQ 9.
The problem is that when you add the mqrfh2 header, its part appears in the body:
SET OutputRoot.MQMD.CodedCharSetId = InputRoot.Properties.CodedCharSetId;
SET OutputRoot.MQMD.Format = 'MQRFH2';
SET OutputRoot.MQMD.Version = MQMD_VERSION_2;
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQRFH2';
SET OutputRoot.MQRFH2.(MQRFH2.Field)Version = MQRFH_VERSION_2;
SET OutputRoot.MQRFH2.(MQRFH2.Field)NameValueCCSID = InputRoot.Properties.CodedCharSetId;
SET OutputRoot.MQRFH2.usr.errorDescription = FIELDVALUE(Environment.Variables.exceptionMsg);
I think you need to read the documentation for an MQRFH2 message. All folders and the header of an MQRFH2 message are in the MQ message body. If the receiving application cannot handle an MQRFH2 message then treat it as a JMS message or a plain message with named properties.
In case you did not know:
MQRFH2 message == JMS message == plain message with named properties (aka message properties)
Updated:
I just noticed this line:
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQRFH2';
This is probably your problem. You are embedding an MQRFH2 message within an MQRFH2 message. Change to it the following:
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR ';
This says that the message data for the MQRFH2 message is to be considered to be string data (i.e. JMSTextMessage).

How to get only MQ messages which are older that 2 minutes in C# usig XMS.net?

I have created an application using IBM XMS.NET. All is good and I am able to read the mssages from queue.
I want to read only those messages which are older that 2 mins from now.
How to use selector in this case. Below is code I have created.
var time = 120000; // 2 mins in miliseconds
var currentTime = (DateTime.Now - DateTime.MinValue).TotalMilliseconds; // current time in milliseconds
long finaltime = Convert.ToInt64(currentTime - time); // Time in milliseconds after substracting 2 minutes
var dtt = Convert.ToInt64(((new DateTime(1970, 01, 01, 01, 00, 00)) - DateTime.MinValue).TotalMilliseconds); // Time in miliseconds till 1970
finaltime = finaltime - dtt; // substracting milliseconds till 1976 as JMSTimestamp shows time after 1970
string selector = "JMSTimestamp <=" + finaltime.ToString();
Here selector is getting set as fixed value for example 1454322340382.
How I can set selector to choose latest DateTime.Now and then look for message older that DateTime.Now - 2 minutes.
Selecting on those messages that are older than 2 minutes is probably the most inefficient way to look at those messages. You don't say why you want to do this. If you simply want to discard them, then I suggest you have the producer of the message add an expiry time on those messages. If you cannot get the producer of the message to change their application to do this, then consider using the CAPEXPRY administrative over-ride.
If you want to look at them, then browsing through all the messages and only operating on those which are the right age would be more efficient that selecting them I'm sure.
Because the selector is passed as parameter at the time of creating consumer, it can be changed without closing and recreating the consumer.
MessageConsumer receiver;
receiver = session.createConsumer(stockQueue, selector);
Update:
Evaluation of selector expression happens during creation of consumer. The
DateTime.Now - 2 expression evaluates to a fixed value and does not change. For example "JMSTimestamp <= 1454322340382". So when a consumer is created with that selection string, consumer will get only those messages that match the above condition.
While the above is fine. But when the consumer is getting messages, new messages can come into the queue. Those message may become older than 2 minutes by the time consumer attempts to get them. Consumer will not get those messages even though they are older than two minutes because their JMSTimestamp is higher, for example 1454666666666. To remove such messages you will have to close the consumer and create it again with updated selector condition.
Hope I am clear.
For your use case, I would go for MQ Base .NET API instead of XMS .NET. First browse messages and if a message is older than 2 minutes remove it.
queueBrowse = queueManager.AccessQueue(strQueueName, MQC.MQOO_BROWSE + MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
try
{
MQMessage msgBrowse = new MQMessage();
MQGetMessageOptions mqgmoBrowse = new MQGetMessageOptions();
mqgmoBrowse.Options = MQC.MQGMO_BROWSE_NEXT;
queueBrowse.Get(msgBrowse, mqgmoBrowse);
TimeSpan ts = DateTime.Now.ToUniversalTime().Subtract(msgBrowse.PutDateTime);
if (ts.TotalMinutes > 2)
{
MQMessage msgDelete = new MQMessage();
msgDelete.MessageId = msgBrowse.MessageId;
MQGetMessageOptions mqgmo = new MQGetMessageOptions();
mqgmo.MatchOptions = MQC.MQMO_MATCH_MSG_ID;
queueBrowse.Get(msgDelete, mqgmo);
Console.WriteLine("Message older than 2 minutes deleted");
}
else
{
Console.WriteLine("Message not older than 2 minutes");
}
}
catch (MQException ex)
{
}

Control MIDI message with AppleScript

The idea of this originally to convert NRPN+/- message to CC (with MIDIPipe)
MidiPipe converts the NRPN messages to CC97 1 and CC96 1
Set the new Channel + CC + Value
on runme(message)
if (item 2 of message = 96) then
set message to {178, 22, 1}
else
set message to {178, 22, 127}
end if
return message
end runme
Makes this output twice as many messages because it is not sensitive enough?
Stop the leak of the original messages? This only seems to add messages not replace
I hope you can help me out how to achieve those last 2 points with AppleScript

Resources