Java Client for MQTT using AWS IoT - java

I am fairly new to the Aws IoT . I am aware that we can write the Java client for Aws IoT. I have below three queries:
Is the Java Client used only to receive messages from the 'Thing' on Aws ?
Can other devices subscribe to the Java Client
Can this client also send messages to other devices
It will be helpful if you could help out with the starting point to implement the Java. References to any articles or links would really helpful.

Is the Java Client used only to receive messages from the 'Thing' on Aws ?
Let's assume under the Java client we will understand the MQTT client. MQTT is a messaging protocol (most commonly used with AWS IoT - at least what I've seen). And you can consider the AWS IoT as a messaging hub.
So your client can subscribe for messages from things or queues to receive messages, but as well your client could send messages to the topics or things (topics reserved for things). All things or devices are effectively messaging clients for the IoT hub.
Can other devices subscribe to the Java Client
I don't full understand your question. So I'll be guessing that your question is about other clients or devices could receive messages from your application? (a device is just another client).
The clients can subsribe to their tpoic (representing a device or functionality). Your application can send a message (see point 1) to a topic for any device it wants.
Can this client also send messages to other devices
sending messages to other devices means sending messages to topics, to which the other devices are subscribed
help out with the starting point to implement the Java
You may check the Eclipse Paho project (MQTT client)

Related

Aws IoT Message Delivery

I am looking into Amazon IoT as a transport mechanism for mobile devices periodically measuring data (usually every N minutes, with N being anywhere between 2 and 32 minutes). With MQTT, I can utilize Amazon's broker to publish finished measurement results to subscribers with QoS=1. Let's also assume that my sole subscriber is just another device listening on wildcard topic (eg. abc/#) and storing published messages into a local database.
But now it's also possible that:
the publishing mobile devices have spotty/bad/no connection to the cell network,
the subscriber dies (reboots, software failure, hardware failure, maintenance, etc.)
Assuming I use the official Java SDK . What would happen to data published during these times when at least either of them is offline? Will the subscriber get all the messages it has been missing out on upon reconnect?
Also: does this depend on the protocol in question? For testing purposes, we're using WebSockets, but later development/production, we'd prefer MQTT over SSL.
What would happen to data published during these times when at least
either of them is offline? Will the subscriber get all the messages it
has been missing out on upon reconnect?
Yes, If you use MQTT with QoS Level 1 or Higher because MQTT employs a Publisher/Subscriber architecture with Topic. Messages destined to Topics with QoS Level 1 and Higher will have the messages in memory and on disk (Atleast mosquitto) by the MQTT server until a Subscriber subscribes.
WebSocket is different. It doesn't have a Publisher/Subscriber architecture. It is a Duplex Communication model on a Single TCP connection. WebSocket initiates as a HTTP connection which will get updated to a WebSocket connection. In case of WebSocket it is the responsibility of the Application to make sure what happens when there are connection problems with Subscribers.

Android application connected to an ActiveMQ server

I wanted to know if it is possible to create an Android Application that sends and receives messages through the ActiveMQ server? if its been done can you show me some examples perhaps?
Thank you for taking the time to read
you can use Stomp Java lib to consume from queues https://github.com/fusesource/stompjms
here an example of android app that talk to activemq https://github.com/jsherman1/android-mqtt-demo
https://dzone.com/articles/android-mqtt-activemq
http://activemq.apache.org/mqtt.html
ActiveMQ supports the MQTT protocol and will automatically map between
JMS/NMS and MQTT clients. MQTT is a machine-to-machine (M2M)
publish/subscribe messaging transport.

JBoss push notification to Android

I have a java application under JBoss and i want to send push notifications to notify the Android device if i needs some particular piece of data, and then the device can send that to the server.
I found two solutions:
- Android Cloud to Device Messaging (C2DM)
- MQTT
I'm new to these message protocols and i'm searching if there is compatibility with JBoss. In particular, for the MQTT, i can't find a MQTT broker for JBoss.
Can anyone help me or suggest me other solution for pushing notifications to Android devices?
Thank you
C2DM has been deprecated by Google. The current version of the Google Push Service is called Google Cloud Messaging.
On your MQTT broker question: You need an MQTT client on Android and you can use any MQTT broker you like for the server part (for example HiveMQ [1]). The Android client subscribes to the broker and your JBoss application is another client, which simple publishes a message that the client receives. For that to happen your MQTT broker needs to be accessible from Android and the JBoss application, and both need to use the same topic.
As client library for both you can use Eclipse Paho [2] and for testing a public mqtt broker [3].
Hope that helps,
Chris
[1] http://www.hivemq.com
[2] http://www.eclipse.org/paho/
[3] http://mqttdashboard.com/dashboard
You can use openmobster (Open source Mbaas)
This Provides a mobile platform-independent Cloud-initiated Push Notification System.( In Android, the push mechanism is based an a persistent socket connection)

How should I go about implementing this SMS notification system?

I have developed a application which involves billing users. To do this i have incorporated a GSM modem (gateway) that the SMS messages are sent through. This SMS message is sent to the user when he is billed with the bill details. The GSM modem is connected to a single computer but the billing can happen in other systems. How do I send an SMS notification for the changes that occur in the other systems, as the GSM modem is attached to a COM port on the computer*.
can we access the COM port of other system or shoould i use socket programming (with the machine with the modem(Server) listening for any connection, the sender has to send data in particular format and the server has to parse the data and send the message) or use Java RMI or is there any other solution.
Suggestions please....
Thank you
There are any number of solutions you can think up. The most common ones would be:
Communication with some kind of RPC, be it RMI, SOAP, plain HTTP, telnet, etc.
Using an SMS gateway such as Nordic Messaging’s EMG (probably overkill, though) or kannel (seems to be down currently).
We've got an SMS Gatway. We wrapped it in a J2EE-application with a webservice interface. That way we can send SMS from any of our applications. For the sake of java we made a little jar-file that talks to the webservice
SmsClient smsclient = new SmsClient();
smsclient.sendSms(from, to, message);
I built a similar system to this in the past where small embedded systems sat on a network and reported messages over the network to a central server that logged the messages and sent SMS messages when required.
I used a java socket listener that waited for UDP messages from the embedded units and the java program wrote to the GSM modem on the servers comm port. UDP was only used instead of TCP as it was simpler to configure on an embedded system.

Using JMS, is there any way to store messages on intermittently disconnected clients and forward them to a broker when a network is available?

I am considering an architecture where I have clients that are intermittently connected to a network. I would like to store messages created on these clients in a JMS queue when the network is not available and have these forwarded to a central message broker when the clients are on the network. (The user has control over the network, e.g. dialing in, so it's not an intermittent connection like with a mobile phone.)
Are there any JMS implementations that provide this feature?
You can embed an activeMQ broker into your application
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
Then, I suppose (did not test) that you could use ActiveMQ features which allow you to dispatch messages accross a net of brokers, using the discovery of brokers feature,
http://activemq.apache.org/clustering.html
or simply by adding a queue consumer server side, then dispatching through other brokers through this consumer.
Hope it helps.
The Glassfish Open Message Queue can be embedded (or run stand-alone) in version 4.4 (Support the ability for a broker to run "in process" with any client.). It is very light-weight, and will support other client languages over the STOMP protocol in version 4.4 - besides Java and C. - https://mq.dev.java.net/4.4.html

Categories