How to get total email conversation with single common identifier in all email messages using java. javaMail API and JMS is giving sender and receiver message id which is different. I need the common identifer which will specify the communication thread.
There is no such thing. If you're trying to correlate messages into a "thread" or "conversation", see this.
Related
I'm building an API that enables clients to send emails to their subscribers. It may be that the subscriber is already registered with an unique id assigned to it. Therefore, a POST /emails/subscribers/:subcriberId endpoint exists that lets the client send an email to the subscriber identified by subscriberId.
Now, a new use case has arisen where a email may be sent to a unregistered subscriber. Instead, the email and the name of it will be specified in the request body.
I'm thinking to implement the following endpoint:
POST /emails
{
// email content and metadata
"receiverName": "John Smith",
"receiverEmail": "john#example.com"
}
It will be nice to use the receiver's data to create a new subscriber for future actions. But this would be a side effect of sending the email.
Is this an acceptable RESTful practice?
Notes:
I want to avoid the client having first to create the subscriber and the sending the email.
Subscribers are also uniquely identified by email.
Is this an acceptable RESTful practice?
Yes.
HTTP constraints the semantics of the request and the response. Implementation side effects are at the discretion of the server.
One way to get around your problem is to provide a POST /emails endpoint whose contract supports both use cases: send emails to subscribers and non-subscribers.
Regarding your API, I suggest you rethink your design as it violates some basic design principles. For instance:
collection resource names should be plural (i.e., /subscribers)
you should review the has-a relationships between your resources (i.e., a subscriber has an email, not the other way around).
If the POST here is associated to the standard CREATE method I think this is actually a side effect. Storing the email is not a side-effect but connecting to a SMTP server and send an email to a any recipient it is.
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
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
I have establish chat communication between two users using jabber-net xmpp client and vysper server by apache.
I am looking for broadcast facility using the same.
There are different mechanisms for "broadcasting", a word which I understand as "sending one message which is distributed by the server to many receivers".
When a user changes his "status" (for example "do not disturb me - I'm coding") a so call "presence" message is sent out which is distributed to all his contacts. This is a broadcast, and presence messages are intended to do that in XMPP.
There is at least another popular possibility: multi-user chat ("MUC"). MUC has the notion of "rooms", where users can "enter" to become part of a "conversation". Every message sent by one of the participants is sent to all others.
There are more similar mechanisms available, depending on what you actually want to do.
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.