GithubHelp home page GithubHelp logo

activemq_websocket_consumer's Introduction

activemq_websocket_consumer

This project runs a javascript that connects to ActiveMQ and registers a consumer using websocket. Other projects (of mine, xxx) shows how to register a listener using Java. But the challenge is to do so from the client - from javascript.

How to Run?

from command line, use the following command:

mvn clean tomcat7:run -Dohadr.project.port=8093

Note that 'ohadr.project.port' is a property that lets you set the port that the application will be listening to. If none is set, the default port is 8080. You can use a different port that 8093, of course.

Debug within Eclipse

See how in this README: https://gitlab.com/OhadR/activemq-spring-sandbox#debug-within-eclipse

Using my own websocket

In the first stage, I wrote my own websocket-backend (ChatEndpoint) with its decoder/encoder. This class is connected via websocket to the front-end (ohad.js). ChatEndpoint.onOpen() registers a listener on ActiveMQ, and when a message is queued, the listener consumes it and notifies ChatEndpoint.onMessage(), which sends the data to the client over the websocket.

Using ActiveMQ's STOMP

The second stage, I realized that ActiveMQ supports STOMP (STOMP stands for Streaming Test Oriented Messaging Protocol, which is a layer over websocket), so there is no need in the backend that I have written. Thus, I wrote direct-amq-websocket.js which uses Apache-ActiveMQ's stomp.js. This code opens a websocket directly to ActiveMQ, and consume messages.

There is a button for sending a single message, for tests, to save time (you do not need to send the message from another application)

References

https://www.baeldung.com/java-websockets

DZone: Easy Messaging with STOMP over WebSockets using ActiveMQ and HornetQ

Application Screenshot

screenshot

activemq_websocket_consumer's People

Contributors

ohadr avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.