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.
Related
What is the difference between channel vs. broker vs. destination in Spring websocket?
I recently started working with a websocket and from what I understood:
registry.addEndpoint("/wsocket/") adds a websocket endpoint which is solely used when clients wants to connect to the websocket service:
this.client.configure({
brokerURL: `ws://localhost:9022/wsocket`,
onConnect: () => {
this.client.subscribe('/quote/fb', message => {
console.log(message);
});
}
});
this.client.activate();
config.enableSimpleBroker("/quote") enables a channel/broker, letting clients to subscribe to it and receive messages published/sent over it. Clients are able to subscribe to any /quote/* on the server.
config.setApplicationDestinationPrefixes("/app") sets the application prefix, which clients use to send message directly to the app and not through the broker.
Is my understanding correct?
I think your understanding is correct .
Broker
A message broker acts as an intermediary platform when it comes to processing communication between two applications. In the context of spring websocket :
When you use Spring’s STOMP support, the Spring WebSocket application acts as the STOMP broker to clients. Messages are routed to #Controller message-handling methods or to a simple in-memory broker that keeps track of subscriptions and broadcasts messages to subscribed users. You can also configure Spring to work with a dedicated STOMP broker (such as RabbitMQ, ActiveMQ, and others) for the actual broadcasting of messages. In that case, Spring maintains TCP connections to the broker, relays messages to it, and passes messages from it down to connected WebSocket clients.
Channel
It can be thought of as a logical segregation of messages in one or both directions. For example, there can be three channels. One for request(incoming to the server), second one for response(outgoing from the server) and third one for error (outgoing from the server).
Destination
It can be thought of another level of hierarchical nesting for a channel. I find this image helpful to understand it :
https://docs.spring.io/spring/docs/5.1.3.BUILD-SNAPSHOT/spring-framework-reference/images/message-flow-simple-broker.png
[![enter image description here][1]][1]
Clients can use the SEND or SUBSCRIBE commands to send or subscribe for messages, along with a destination header that describes what the message is about and who should receive it. This enables a simple publish-subscribe mechanism that you can use to send messages through the broker to other connected clients or to send messages to the server to request that some work be performed.
I find Spring documentation on this topic to be very helpful : https://docs.spring.io/spring/docs/5.1.3.BUILD-SNAPSHOT/spring-framework-reference/web.html#websocket-stomp-handle-simple-broker .
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)
Is there any way to get notification from server whenever it is on?
my requirement is when ever ActiveMQ is on a piece of code will run automatically
in ActiveMQ is there is no load on startup
Create a publisher in your language of choice that periodically sends a test message to ActiveMQ.
Create a subscriber in your language of choice that receives the test messages and notifies you via your mechanism of choice that it has successfully received a test message.
The Apache ActiveMQ broker supports discovery with IP multicast.
Applications can use discovery for JMS clients to auto-detect a Message Broker to connect to.
This could also be used to monitor a broker's status, using Java MultiCast support.
To invoke a piece of code when the broker is started, you can perhaps base it off either an embedded Camel route or broker interceptor. The idea being that when the broker is started, so will these components and thus allows them to issue whatever sort of notification you require.
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)
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