Amazon Elastic Beanstalk Broadcast - java

I would like to develop a simple chat, but for that I need to inform all clients that a user wrote a message. Simple with one server instance, but how it works with 2+...
Is there a way to inform all registered instances in my beanstalk or how can I resolve this problem.
Thanks for help!
Regards,
Rookee

Given your setup, the best solution is to use Amazon's SNS. This is equivalent to a JMS Topic, so, your app can subscribe to events published by other parties (probably the same app running in another instance) on the topic. Then, each consumer of the topic would broadcast the chat message to the users connected to said server.
http://aws.amazon.com/sns/

Related

Mqtt Check if a client is online or offline

I am using mqtt and mosquito broker to build a simple instant chat for an android platform. Now I wanted to implement a condition where any client can check if another client is online.
I know about Last will and testament but I wanted a user to be detected offline only wen the application is inactive or the user is not currently using the app.
I actually dnt need any code, buh wanted an idea as to how to implement this and I would be much grateful.
You can do this without relying on MQTT internals which is much easier in my view. With this approach, you have much more control over what is going on:
The client can periodically send a message within another topic to inform the server of its availability. In case the server does not receive that message after a specified amount of time, it can assumed that it is offline.
The client can also send another message if the user logs out and inform the server a well.
If you insist on using MQTT internal structure, you may find this question useful:
How to Find Connected MQTT Client Details

How to receive sms in a web application in java ?

i'm trying to create a web application that sends and receive SMS. I've already contacted a local SMS gateway and the connection is working.
I'm using Jsmpp as the library and i'm able to send and receive SMS through a sample application i build using Java SE.
Now i need to migrate this feature to web application. Sending SMS should be ok. But how can i add a listener to listen to the SMSC through my web application ? I'm using Spring and j2ee.
The SMSC doesnt expose a web api and dont have the ability to send sms to a api i expose. The only way they allow is the communicate through the SMPP protocol.
Thanks In Advance.
did you try the program in the link - http://www.java-samples.com/showtutorial.php?tutorialid=22?
If you are looking for any Bulk SMS Solution, You can use APIs provided by vendors such as https://www.textlocal.in/ or any other vendor whichever is feasible.
If you are looking to setup a gateway for yourself, you can check a solution like http://www.ozekisms.com/
Earlier there were Network Vendor provided Gateway which you can freely use, now there are no such gateway you can use freely.
More links,
https://www.quora.com/How-can-I-send-a-SMS-with-a-Java-code
http://www.airtel.in/aes/Global+Business/Global+Voice/Enterprise+Voice+Solutions/Mobility+Solutions/Enterprise+VAS/Bulk+SMS+Solutions
After lots of trial and error i managed to find a solution for the question.
The way i implemented it was to run a standalone java application as a Linux service that would listen to the SMSC. I used the sample project SMSRouter (https://smsrouter.org/) as the basis. Apache camel smpp component was used in this sample project to handle sms sending and receiving.
I then created queues inside Jboss application server for inbox and outbox to store incoming and outgoing sms messages.
Once a SMS is received by SMSRouter it will use JMS to add the SMS message to the inbox queue inside Jboss which will trigger a Message Driven bean that would keep listening to the inbox queue.
When the Web Application needs to send a SMS it will add a JMS message to the outbox queue which will then trigger the SMSRouter which is listening to the outbox queue. SMSRouter will use Apache Camel to send the SMS to the SMSC.

GCM device to device messaging - how is it done?

I'm interested in how apps like WhatsApp implement this feature.
I've just read that it's bad practice to send the message directly from device to device, because someone can eventually get to the API key and send messages as my application.
What's the solution then? Having a server and making the devices only communicate with this server, so when I want to send a message to another device, it goes to the server and from server to that target device?
Also another question:
public void onMessageReceived(String from, Bundle data)
This is a method of the GcmListenerService. When is "from" different than the default senderID? Because I tried sending the message directly from one device to another and the "from" was still the default senderID that I got when I registered the app on the website.
Basically, you need a server to listen to upstream messages and broadcast then again to intended recipients.
You can find an article describing this here: http://javapapers.com/android/android-chat-with-google-gcm-xmpp/
The approach is pretty limited and not as flexible as having your own messaging server, but should be enough for a proof of concept.

Manage Topics on Mosquitto

I want to develop a simple push notification system for various android devices.
After two days of documentation i've found very interesting to use MQTT protocol.
System needs:
- an MQTT client on Android: eclipse Paho seems to be a good solution
- any MQTT broker you like for the server part: my attention is on Mosquitto cause is Open-Source
I've read documentation and the configuration file and seemed clear. The only thing that I couldn't understand is if i can manage topics (where clients subscribe to). In particular if i can create topics and how to.
Thanks.
It's not clear whether you mean on the client side or the broker side...
Assuming you mean the broker side, you don't need to create topics, they are created automatically as needed. You can control what clients have access to what topics using the built in authentication and ACL code, or you could use an authentication and access plugin. Writing your own is quite easy, or you could use the excellent https://github.com/jpmens/mosquitto-auth-plug
On the client side, simply subscribing or publishing to a topic is sufficient to create it on the broker, assuming you have permissions for that topic. This may not be the case in all MQTT implementations.
As an example, try subscribing to the # topic on test.mosquitto.org or iot.eclipse.org. These show a huge range of available topics and there is no admin to support them in the background.
This basically means that the only administrative load you have is restricting access on the broker where required.
Using code stole from somewhere, I made a pretty simple "MQTTMessenger" app for Android. https://bitbucket.org/mjgasner/mqttmessenger
From what I remember, you'll need to go into src/com/gasner/mqttmessenger/MessengerService.java
and change the host ip to the ip of your MQTT server.
For the MQTT server, I used Mossquitto server.
You'll also have to make sure you port forward port 1883 to the server.
I used this to send stock numbers to my phone. It's been almost 2 years ago, otherwise I could tell you more.
The C2DM directory is unrelated. It is Google's push notification service that I was also playing with at the time.
In the other directories at Bitbucket https://bitbucket.org/mjgasner are the .NET service and winforms app I wrote to communicate with the MQTT server. The service would accept the message from the android app through the server and reply with the stock amount it pulled from google's api.
If you have any more questions, comment below.

Using JMS in RESTFull Web services

I am developing the Rest Full services in Java+Spring, that can be used by Mobile Apps(iPhone+Android) and on Web Applications.
Would it be better choice to choose JMS(Java Messasing service) for Sending asynchronous and Reliable Email messages to Mobile Apps and Web application or is there any better alternative other than JMS for asynchronous messaging. Please help.
EDIT :
I want my RESTFull web services to send email messages that not only provide the guarantee of delivery of the Email messages but also use the asyancronous messaging mode so that server would not be waiting for reciever to recieve the message. Also please suggest if i use JMS at server end to Publish/Produce the messages in a Queue, how will the Mobile Apps will recieve the messages from the JMS Queue? Is it possible for IPhone/Android/PHP web application to recieve the message that was published by JAVA server.
Thanks,
Arun Kumar
JMS isn't appropriate for mobile applications. Mobile applications can't be expected to be always running and listening for connections. For these reasons Push Notifications are used for sending messages to mobile devices. Both Apple and Google offer this kind of services.

Categories

Resources