GithubHelp home page GithubHelp logo

invoca / stomp_out Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flexera-public/stomp_out

0.0 2.0 1.0 71 KB

Transport-independent implementation of the STOMP message exchange protocol.

License: MIT License

Ruby 100.00%

stomp_out's Introduction

<img src=“https://travis-ci.org/rightscale/stomp_out.svg?branch=master” alt=“Build Status” />

Introduction

StompOut is an implementation of the Simple Text Orientated Messaging Protocol (STOMP). Both a client and server interface to the protocol are provided. They are implemented independent of the underlying network protocol over which they are applied. In that sense they run outboard of the underlying connection, hence “Out” in the name. The Client and Server classes provide a function for receiving blocks of STOMP encoded data from the connection and they expect the subclass to implement a function for sending data that has been STOMP encoded over the connection.

The Client and Server classes support version 1.0, 1.1, and 1.2 of STOMP. The built-in version negotiation in the protocol determines which is actually applied for a given connection.

Interface

Client

There are two parts to the interface: the functions the StompOut::Client class exposes and the functions the Client subclass must implement.

The Client exposes the following functions:

  • receive_data - process data received over connection from server

  • connect - connect to server

  • message - send message to given destination

  • subscribe - register to listen to given destination

  • unsubscribe - remove an existing subscription

  • ack - acknowledge consumption of a message from a subscription

  • nack - tell the server that a message was not consumed

  • begin - start a transaction

  • commit - commit a transaction

  • abort - roll back a transaction

  • disconnect - disconnect from the server

  • subscriptions - list active subscriptions

  • transactions - list active transactions

The Client subclass must implement the following functions:

  • send_data - send data over connection to server

  • on_connected - handle notification that now connected

  • on_message - handle message received from server

  • on_receipt - handle notification that request was successfully handled by server

  • on_error - handle notification that a client request failed and connection should be closed

Server

There are two parts to the interface: the functions the StompOut::Server class exposes and the functions the Server subclass must implement.

The Server exposes the following functions:

  • receive_data - process data received over connection from client

  • disconnect - stop service in anticipation of connection being closed

  • message - send message from a subscribed destination to client

The Server subsclass must implement the following functions:

  • send_data - send data over connection to client

  • on_connect - handle connect request from client including any authentication

  • on_message - handle delivery of message from client to given destination

  • on_subscribe - subscribe client to messages from given destination

  • on_unsubscribe - unsubscribe client from given destination

  • on_ack - handle acknowledgement from client that a message has been successfully processed

  • on_nack - handle negative acknowledgement from client for a message

  • on_error - handle notification that a client or server request failed and connection should be closed

  • on_disconnect - handle request from client to close connection

The above functions should raise StompOut::ApplicationError for requests that violate any application specific constraints.

Example

The gem contains client and server examples of how it can be applied in a WebSocket environment. The server example can be run in the examples directory using thin:

thin -R config.ru start

The client example is a script that can executed against the server, e.g., to produce messages:

./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -m "hi"
./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -m "bye"

and to consume messages:

./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -a client -r

Dependencies

The eventmachine gem is used only if the STOMP heartbeat feature is used. The the json gem is used by the Client only if a content-type is “application/json” and the :auto_json option is enabled. The examples make use of the faye-websocket, eventmachine, trollop, and json gems.

License

This software is released under the MIT License. Please see LICENSE for further details.

Copyright © 2015 RightScale

stomp_out's People

Contributors

leekirchhoff avatar dominicm avatar alecjacobs5401 avatar

Watchers

James Cloos avatar  avatar

Forkers

isabella232

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.