MUC, XMPP - Unread messages counter, last message - xmpp

Is it possible without joining to the room to get:
the number of unread messages from MUC? I have seen similar questions ~7 years ago but still didn't find such solution. Or is it possible to get information if there is a unread message?
the last message that was written in the room?
Thanks

Is it possible without joining to the room to get:
If the MUC room has archiving enabled, anybody can query it as shown in https://xmpp.org/extensions/xep-0313.html#example-5
For example:
<iq to='room1#conference.localhost' type='set' id='juliet1'>
<query xmlns='urn:xmpp:mam:2' queryid='f28' />
</iq>
The response includes all the room messages:
<message to='user1#localhost/tka1'
from='room1#conference.localhost'>
<result id='1652698091920538'
queryid='f28'
xmlns='urn:xmpp:mam:2'>
<forwarded xmlns='urn:xmpp:forward:0'>
<message xml:lang='es'
from='room1#conference.localhost/admin'
type='groupchat'
id='44:501539'
xmlns='jabber:client'>
<archived by='room1#conference.localhost'
id='1652698091920538'
xmlns='urn:xmpp:mam:tmp'/>
<stanza-id by='room1#conference.localhost'
id='1652698091920538'
xmlns='urn:xmpp:sid:0'/>
<body>mensa 1</body>
</message>
<delay from='conference.localhost'
stamp='2022-05-16T10:48:11.920538Z'
xmlns='urn:xmpp:delay'/>
</forwarded>
</result>
</message>
the number of unread messages from MUC? I have seen similar questions ~7 years ago but still didn't find such solution. Or is it possible to get information if there is a unread message?
"Unread" is a concept that only the client knows, not the server. The client must tell the server what was the last message the client has read. Maybe using https://xmpp.org/extensions/xep-0313.html#filter-time
the last message that was written in the room?
At a quick look I didn't find anything for that in XEP-0313. If you take a closer look, maybe you find some solution.

Related

Bitcoin node interaction, message orders

can anyone tell me exactly how interactions between bitcoin nodes happens?
I mean i need the order of messages the nodes send and receive.
For example i know that the first message that two nodes exchange is "version" and "verack" messages but often between "version" and "verack" they send many other messages like "sendcmpct", "getheader"... etc, but other times they only send "version" and "verack" before any other messages.
Maybe this article can help (check all Key points)
https://nownodes.io/blog/how-bitcoin-works/

Fix.4.2 protocol implementation(Fiximulator - Banzai(client)) message log

I am trying to implement Fix.4.2 protocol, but It is difficult to understand the message log I attached below. Here Logon(35=A) request was sent with MsgSeqNum(34=1) from client. Then for testing ResendRequest and SequenceReset session level messages I sent a NewOrderSingle request with MsgSeqNum=7 (instead of MsgSeqNum=2, as subsequent messages should have incremeted msgseqnum after logon request). As expected MsgSeqNum is too high than recieved one Fiximulator responded with a ResendRequest(35=2) to send from 2 to 0 (i.e., from 2 to 7). Here why the Fiximulator is not waiting for client's reply ? instead it is sending an heartbeat message. Why the client is sending ResendRequest in response to ResendRequest of Fiximulator instead of sending SequenceReset message ?.
Also explain remaining cases if possible.
Thanks in advance.
What is your status of ResetOnLogon in your config file for the acceptor ? Default value is N so it isn't being reset. Always check your config file or try debugging to figure out issues.
ResetOnLogon Determines if sequence numbers should be reset when recieving a logon request. Acceptors only

JMS messages moving to DLQ

JMS mesages are sometimes moving to the DLQ without throwing any exception.
Jboss server instance used is 4.3.0.GA_CP04_EAP.
We are using an an MDB that listens for incoming messages on a queue A, when it receives any message it updates the database and sens an email in one transaction.Transaction is CMT.
Now, what is happening is, sometimes mesages are not picked up by the consumer and they end up in the DLQ. Though from the JMX- console message count i could see that the message once did arrive to the queue A but then goes to the DLQ.
This happens intermittently and does not throw any exceptions on the logs either .
What seems to work most of the times is restarting the servers. No idea about what happens behind the scenes though.
**And after 29 days, same problem has returned.
This follows a pattern but varies with every restart.
There are 2 clustered serevrs which also do loadbalancing , P1 and P2.
First two email messages go to and processed by P1-Email sent
Next email message resquest goes to P2-Email sent
Next two email messages go to and processed by P1-Email sent
Next email message resquest goes to P2-Email NOT SENT
and the cycle repeats
I have found a workaround to this nagging problem thanks to the helpful info found at http://leakfromjavaheap.blogspot.in/2013/05/when-dead-letter-queue-becomes-zombie.html
DLQ listener is set up to listen for any incoming messages and puts them back to their intended destination if any of them is found on DLQ.
Also, considering the situation where any message is travelling from DLQ to the Queue and back to the DLQ in endless loops, a counter is set to check how many times the message has been to the DLQ before, if it exceeds the limit, then it is put to a Permanent DLQ (DLQ for a DLQ).
Application has been running smoothly ever since.
If you can provide the log details when message goes to DLQ, would be better to dig into this issue.
The logs did not contain any useful info; not even an exception to give a hint.
Finally,changed the local tx data source to xa data source and it was a success.Still wondering if there is a reason behind it.

With how many resources can a user log into a standard compliant XMPP server?

Simple question: is there any restriction on the number of concurrent logins using the same bare JID but different resources in the XMPP standard?
unlimited, there is no restriction in the RFCs
It is implementation-defined, with no set maximum in the RFCs. However, RFC 6120, section 7.6.2.1 says:
If the account has reached a limit on the number of simultaneous
connected resources allowed, the server MUST return a stanza error (Section 8.3.3.18).
S: <iq id='tn281v37' type='error'>
<error type='wait'>
<resource-constraint
xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
Therefore, it is not true that there is no limit, just that each server installation can make different decisions about what the limit is.

Replacing a message in a jms queue

I am using activemq to pass requests between different processes. In some cases, I have multiple, duplicate message (which are requests) in the queue. I would like to have only one. Is there a way to send a message in a way that it will replace an older message with similar attributes? If there isn't, is there a way to inspect the queue and check for a message with specific attributes (in this case I will not send the new message if an older one exists).
Clarrification (based on Dave's answer): I am actually trying to make sure that there aren't any duplicate messages on the queue to reduce the amount of processing that is happening whenever the consumer gets the message. Hence I would like either to replace a message or not even put it on the queue.
Thanks.
This sounds like an ideal use case for the Idempotent Consumer which removes duplicates from a queue or topic.
The following example shows how to do this with Apache Camel which is the easiest way to implement any of the Enterprise Integration Patterns, particularly if you are using ActiveMQ which comes with Camel integrated out of the box
from("activemq:queueA").
idempotentConsumer(memoryMessageIdRepository(200)).
header("myHeader").
to("activemq:queueB");
The only trick to this is making sure there's an easy way to calculate a unique ID expression on each message - such as pulling out an XPath from the document or using as in the above example some unique message header
You could browse the queue and use selectors to identify the message. However, unless you have a small amount of messages this won't scale very well. Instead, you message should just be a pointer to a database-record (or set of records). That way you can update the record and whoever gets the message will then access the latest version of the record.