try {
XMPPConnection conn = XMPPConnect.getConnection();
if (attachmentUrl == null) {
// send a normal message without an attachment
ChatManager chatmanager = ChatManager.getInstanceFor(conn);
Chat newChat = chatmanager.createChat(to, new MessageListener() {
public void processMessage(Chat chat, Message message) {
logger.debug("Received message on XMPP: {}", message.getBody());
}
});
try {