Frontend subscription to MQTT Broker over Websockets - websocket

In my backend I have a MQTT broker. In the frontend I want to represent this values by subscribing to the MQTT topics.
It is a good practise to directly subscribe the frontend to a MQTT broker via WSS?
If not, what are recommended alernatives?
If yes, how is the authentication been done?

Related

Bridge between two WebSocket STOMP servers

We have an ActiveMQ server and our own API with WebSocket/STOMP service endpoint.
Is there a way to configure ActiveMQ to connect and subscribe to a topic in our API and then publish the messages in ActiveMQ?
If not, are there any other WebSocket/STOMP bridge components which could be used to achieve the same thing (subscribe to a topic in our API and post messages to a topic in ActiveMQ)?
The motivation of all this is... complicated.
ActiveMQ natively supports Camel routes. You could potentially use Camel's STOMP component to subscribe to your own STOMP endpoint and then send those messages to a local destination.

spring integration mqtt over udp or mqtt-sn

In IoT scenario a lot of standard force pushing packets to mqtt queues over UDP protocol. This scenario become more and more frequent day by day, and for this reason now we have a new kind of mqtt queues named mqtt-sn.
In spring-integration-mqtt I'm using a paho client, however this has a specific client implementation ready to use mqtt-sn (https://eclipse.org/paho/clients/c/embedded-sn/) and there is also an implementation of moquitto over mqtt-sn (https://github.com/eclipse/mosquitto.rsmb).
There is any way to for spring-integration-mqtt over UDP protocol or there is an implementation which allow to use mqtt-sn over spring-integration?
Most (if not all) MQTT-SN broker bridge the messages to MQTT topics so just use the normal Spring/MQTT integration with a suitable broker.

Can we send messages between two clients using different protocols(STOMP - TCP) with ActiveMQ?

I have a scenario , where i have my sender code written in Node.js which uses STOMP protocol to publish it to the destination(queue) and the receiver code written in java which use TCP protocol to receive the message from the destination(queue) through ActiveMQ server.Will it be possible for the clients(sender/receiver) to communicate? or it should be the same protocol at either end?
The ActiveMQ documentation covers this on the Stomp page (http://activemq.apache.org/stomp.html) in the paragraphs
Working with JMS Text/Bytes Messages and Stomp
Message transformations
Stomp extensions for JMS message semantics
ActiveMQ extensions to Stomp
ActiveMQ supports richt message conversion between messages from different protocols. Not all multi-protocol have this feature, for example ActiveMQ Apollo (issue 267).
Not an issue. ActiveMQ acts as a multiprotocol message exchange so messages received by the broker in any supported protocol can in turn be sent to receivers in any other supported protocol.

How to receive message published on a topic using mqtt protocol in spring:jms application?

I am new to activemq.
I have a publisher which publish a message to a topic using mqtt protocol. And now I want to write a subscriber using Spring + JMS which will listen for the message on that topic.
I have following questions:
1) Can I have a same topic if I write the subscriber using tcp protocol.I mean to say, publisher will use MQTT to publish on a topic and subscriber will listen on that topic using TCP broker URL.
2) If above is not possible then how can I write a subscriber using spring + jms that will listen and receive the messages published on the topic using mqtt ?
Thank you in advance.
Did you even try? Yes, it works pretty much as you expect it to. MQTT msgs gets converted to JMS if you try read it with JMS (OpenWire).
From web site:
Message transformations
MQTT messages are transformed into an JMS
ByteMessage. Conversely, the body of any JMS Message is converted to a
byte buffer to be the payload of an MQTT message.

What's the best way to integrate a mqtt broker with tomcat

I have a tomcat7 application currently accepting https calls which carry a JSON payload. So this work perfectly in a client/server relationship.
I want to be able to push data out to 'clients' so am investigating using MQTT. This work fine - I can publish/subscribe messages between MQTT broker and the 'clients'.
I want now to be able to re-use my Tomcat code. Do I configure tomcat to publish/subscribe to MQTT topics? Do I make some 3rd process which subscribes to MQTT topic and calls into tomcat.
I'm at the beginning of my investigation stage of a project. Any help/recommendations are appreciated.
Yes it is possible, there are many client libraries available (e.g. Poho for Java), so your server can subscribe/publish messages. Now to handle multiple messages published from various clients, implement a message queue.
Checkout this, RabbitMQ MQTT Adapter
https://www.rabbitmq.com/mqtt.html

Resources