How can a Bayeux Client stop receiving messages from Bayeux Server? Is there a way to block the channel between client and server at the client side? - cometd

At the server, CometD provides a MaxQueueListener hook to drop messages but if the Bayeux Client wants to stop receiving messages from a server without disconnecting , can it achieve that?

A BayeuxClient receives message from the server only for the channels it is subscribed to.
For a BayeuxClient to stop receiving messages from the server is enough to unsubscribe from all channels it subscribed to.
The BayeuxClient will still receive meta messages on meta channels that are part of the Bayeux protocol, but no application message will be delivered by the server.

Related

What is the flow of a request to a server with a queue in the middle?

I'm trying very hard to understand the flow of a web request to a server which has a queue or message broker in the middle, but I can't find information about when and where the reply is given.
Imagine this use case:
Client A:
sends a invoice order request
the invoice is enqueued
the request is processed and dequeued.
at which time the client will receive a response?
right after the message is received by the queue?
right after the message is processed and dequeued? Other?
I'm asking because if the reply only comes after the message being processed the client might wait a long time. Imagine the message takes 3 minutes to process, would the client need to keep requesting the server to see if it is processed? or a connection is maintained using something like long polling?
I'm interested in scenarios using RabbitMq and kafka.
Advantage of having a messaging system is to ensure the frontend webserver and backend processing is decoupled. Best practice is Web server should publish the message and just wait for the messaging system to acknowledge receiving the message.

Ejabberd with Stream management (XEP-198) not using offline message hook

We are developing an app with a chat feature. We have an ejabberd (15.02) configured to use mod_offline_post to use the offline message hook and forward all messages for offline clients to an url of our own which then forwards to the GCM.
However as we are developing an app, we also need XEP-198 (stream management) enabled to handle connection loss. This is working fine in itself. Streams are created and resumed, messages are acknowledged.
The problem is, that the jabber is waiting for a stream to resume and is not forwarding any offline messages to the offline message hook and thus to our mod and post url. It is storing them in its offline storage of course and they get delivered when the recipient resumes its stream.
Is there any way to configure the jabber to call the offline message hook while ejabberd_c2s:fsm_next_state:2517 Waiting for resumption of stream for... ?
PS: We use smack on the client side to provide stream management
In my understanding the behaviour of ejabberd is correct from the XMPP specification point of view. It is doing the right thing and should not in that case forward message to the offline store, because you are not offline technically.
It is just not the right place to place your push processing.

MSMQ: incoming traffic, but messages don't show up in the queue

I'm transferring our web application to new infrastructure and I'm stuck at the MSMQ part.
1st screenshot: Server A sends messages to server B. I see the outgoing messages appear on server A.
2nd screenshot: Server B shows incoming traffic, but the messages don't appear in the queue.
The service picking up the messages at server B is not running!
Any ideas how to debug this situation?
The status of the outgoing queue is connected but the messages aren't moving. Likely to be that the acknowledgement messages are not being sent back successfully from server B. As server A never sees the acknowledgements, it is stuck in a permanent state of retrying to send awaiting a response. There should be an outgoing queue on server B pointing back to server A. Check its status. It is very likely that the IP address of the outgoing queue is incorrect.
If the messages are queuing in your outgoing queue on server A that means that they are definitely not being sent to the destination queue on server B.
If you have messages arriving on server B but not being delivered then this is probably due to queue permissions. However, based on your assertion that messages queue up on the outbound queue I can't see how server B can be receiving any messages.

Sending message from server to client without managing sockets

Im building a chat app for iPhone and im using NSURLConnection with HTTP Post and Get to send messages from client to server. From what i understand this is a non-persist connection, because NSURLConnection open and close connection for each HTTP request, am i right??
In my server i just response to this messages.
My main problem is how to send a message from client A to client B?
client A sends the message to the server with HTTP POST, but how can i send the message from the server to client B if im not keeping a persists connection to client B?
You could make use of push notifications to inform the client that it has an unread message.

Send XMPP message without starting a chat

I am basically writing a XMPP client to automatically reply to "specific" chat messages.
My setup is like this:
I have pidgin running on my machine configured to run with an account x#xyz.com.
I have my own jabber client configured to run with the same account x#xyz.com.
There could be other XMPP clients .
Here is my requirement:
I am trying to automate certain kind of messages that I receive on gtalk. So whenever I receive a specific message eg: "How are you" , my own XMPP client should reply automatically with say "fine". How are you". All messages sent (before and after my client replies) to x#xyz.com but should be received by all clients (my own client does not have a UI and can only respond to specific messages.).
Now I have already coded my client to reply automatically. This works fine. But the problem I am facing is that as soon as I reply (I use the smack library), all subsequent messages that are sent to x#xyz.com are received only by my XMPP client. This is obviously a problem as my own client is quite dump and does not have a UI, so I don't get to see the rest of the messages sent to me, thereby making me "lose" messages.
I have observed the same behavior with other XMPP clients as well. Now the question is, is this is a requirement of XMPP (I am sorry but I haven't read XMPP protocol too well). Is it possible to code an XMPP client to send a reply to a user and still be able to receive all subsequent messages in all clients currently listening for messages? Making my client a full fledged XMPP client is a solution, but I don't want to go that route.
I hope my question is clear.
You may have to set a negative presence priority for your bot..
First thing to know is that in XMPP protocol every client is supposed to have a full JID. This is a bare JID - in your case x#xyz.com with a resource in the end e.g. x#xyz.com/pidgin or x#xyz.com/home (where /pidgin and /home are the resource). This is a part of how routing messages to different clients is supposed to be achieved.
Then there are the presence stanzas. When going online a client usually sends a presence stanza to the server. This informs about e.g. if the client is available for chat or away for lunch. Along with this information can be sent a priority. When there are more than one clients connected the one with the highest priority will receive the messages sent to the bare JID (e.g. ClientA(prio=50) and ClientB(prio=60) -> ClientB receives the messages sent to x#xyz.com). But there are also negative priorities. A priority less than 0 states that this client should never be sent any messages. Such a stanza might look like this
<presence from="x#xyz.com/bot">
<priority>-1</priority>
</presence>
This may fit your case. Please keep in mind it also depends on the XMPP server where your account is located, which may or may have not fully implemented this part of the protocol.
So to summarize: I recommend you to look through the Smack API how to set a presence and set the priority to <0 for your bot client right after it connected.