How cometd server send response to /meta/connect message - cometd

How CometD send response to a /meta/connect message.
Also how cometd receive/send message received on any broadcast channel. Are there any message queues involved?
If there is queue involved then will /meta/connect will also be en queued into this? Does this queue exist on client side as well?

You may want to read the CometD documentation, in particular the CometD Concepts.

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.

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?

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.

Message brokers - "message has been read" acknowledgment solution

I am implementing a service that dispatches messages to clients using an arbitrary message broker. A single user may have multiple clients and the message will be dispatched to each one of them. Once the user has read the message on one client, I want the message removed from the user's other clients.
Do message brokers typically implement this functionality, or will I need a custom solution?
For a custom solution, I was thinking that the broker could maintain a separate reply topic to which a client will deliver a message to say that the user has read the message. The service can consume messages on this reply topic, and dispatch another message to the user's other clients that tells them to remove the message.
Is this how such a solution might typically be implemented?
If it helps, I am considering using MQTT as a message protocol.
There is no concept of even end to end message delivery notification in the MQTT protocol1, let alone read notification. You are likely to need to implement this your self.
If I was doing this I would have 2 topics per user something like this:
[user id]/msg
and
[user id]/read
I would make the payload of the messages delivered to the [user id]/msg contain a message id. I would then publish the message id on the [user id]/read topic. All clients would subscribe to both, that way they could easily mark as read/remove messages as they were consumed on other clients.
1confirmation for higher QOS levels are between the publisher and the broker and then between the broker and the subscriber

Spring-integration: Put message into JMS queue only if e-mails has been sent

I want to send a mail and only if this works put a message into a JMS queue.
How can I do it? I couldn't find any mail:outbound-gateway.
OBS: By now a am using publish-subscribe-channel, but this is not exactly what I need.
OBS: By now a am using publish-subscribe-channel, but this is not exactly what i need.
Why not?
There are several techniques to do this:
Publish subscribe channel with the JMS endpoint the second subscriber (mail order="1", jms order="2") (with ignore-failures="false" - the default).
Recipient List Router
Expression Evaluating Request Handler Advice

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.