SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Real-time Web with Rails
and XMPP
Münchner Ruby on Rails User Group, 2010/12/2

Li Cai (ca168168@gmail.com)
founder: reliwa.de
partner & ex-CTO: 16ds.com
Motivation: 16ds.com

• B2B portal and business network for the
  chemical industry
• Market indexes for 30+ bulk chemicals
  based on prices submitted by diverse
  market players
• Real-time multi-party price negotiation
                                 Münchner Ruby on Rails User Group, 2010/12/2
Multi-party price negotiation
•   User self-organized
•   Access control based on organizational structure of the
    company
•   Customizable quotation templates for each product
•   Configurable admission control and protection of sensitive
    data (customer identities, price details, etc.)
•   Different negotiation modes: fixed price, bargaining, bidding,
    moderated bidding
•   Real-world near auctions by utilizing “Counting-Down-
    Hammer”


                                                Münchner Ruby on Rails User Group, 2010/12/2
Server push in Rails
•   Polling: simple (but...)
•   Comet: setup external server for server push (Jetty,
    glassfish, cometd, ErlyComet, node.js, etc.)
•   FlashXML Socket: full-duplex TCP stream socket
    connection (extra work for firewall traversal)
•   XMPP/BOSH: bidirectional streams over HTTP
    connection
•   WebSockets: full-duplex over single TCP socket is
    being standardized by the W3C (HTML5)

                                         Münchner Ruby on Rails User Group, 2010/12/2
XMPP
•   eXtensible Messaging and Presence Protocol
•   Data exchanged over a pair of XML streams
    •   extensibility: very easy to add new features to the protocol
•   XMPP Toolkits
    •   presence
    •   instant messaging
    •   Multi User Chat (XEP-0045)
    •   Publish/Subscribe (XEP-0060)
    •   and many more...


                                                   Münchner Ruby on Rails User Group, 2010/12/2
XMPP
•   BOSH (XEP-0124, XEP-0206)
    •   long-lived bidirectional streams over HTTP connection
    •   hide user credentials by session attachment
    •   many XMPP servers have BOSH connection manager
        build-in
•   XMPP Component (XEP-0114)
    •   stand-alone server process written with whatever
        language you like
    •   easily extend the server with your own application logic


                                                Münchner Ruby on Rails User Group, 2010/12/2
Extend XMPP with our new
features
•   Build multi-party price negotiation on top of MUC
•   Create XMPP account for every user, while hiding the
    credentials by using session attachment
•   Create MUC-rooms on demand, and manage the member
    list by our application
•   Implement an XMPP component to interact with our
    application as well as the clients
•   Extend name space and let our application handle stuffs
•   Configure default settings of the XMPP server for security


                                             Münchner Ruby on Rails User Group, 2010/12/2
Rails and XMPP


                                Application                        Background
  Web Client   HTTP Server
                             Instances (Rails)                     Jobs (Rails)


               BOSH Conn.
                                                 Message Queue
                Manager


                              XMPP Server
               XMPP Server
                              Component




                                                          Münchner Ruby on Rails User Group, 2010/12/2
XMPP servers
•   ejabberd
    •   written in Erlang, well-known for its scalability
    •   http://www.process-one.net/en/ejabberd/
•   Openfire
    •   written in Java, very easy to install and configure
    •   http://www.igniterealtime.org/projects/openfire/
•   Tigase
    •   written in Java
    •   http://www.tigase.org/
•   and much more...


                                                            Münchner Ruby on Rails User Group, 2010/12/2
XMPP libraries - server side
•   xmpp4r
    •   feature-rich, threaded ruby
    •   http://home.gna.org/xmpp4r/
•   blather
    •   lightweight, DSL-style, evented ruby
    •   http://sprsquish.github.com/blather/
•   skates
    •   lightweight, MVC-style, evented ruby
    •   http://skates.rubyforge.org/
•   strophe-ruby
    •   ruby binding for libstrophe, can be run within a Rails-app
    •   https://github.com/yong/stropheruby



                                                                 Münchner Ruby on Rails User Group, 2010/12/2
XMPP libraries - client side
•   strophe.js
    •   JavaScript
    •   http://code.stanziq.com/strophe/
•   xmpp4js
    •   JavaScript
    •   http://xmpp4js.sourceforge.net/
•   XIFF
    •   Flash/ActionScript
    •   http://www.igniterealtime.org/projects/xiff/
•   and many more...


                                                       Münchner Ruby on Rails User Group, 2010/12/2
Example: user submits a bid

XMPP Comp.                                                          User M                   User A                 User B
                    XMPP MUC                        Web App
  (Spider)                                                        (Moderator)             (Participant)          (Participant)



                                                                                  submit bid

                               room_jid, user_jid, [bid]



     groupchat:x.spider_bid.submitted [bid w. public info]

                                                                update bid_list        update bid_list         update bid_list

     private? && msg:x.spider_bid.submitted [bid w. all info]
                                                                update bid_list        update bid_list




                                                                                  Münchner Ruby on Rails User Group, 2010/12/2
Example: user submits a bid

Rails:
# class RoomBid < ActiveRecord:Base

def submit

  # ... authorization check and application level processing ...

  Spider.notify "bid.submitted", {
     :room_jid => room.jid,
     :bid => public_info.to_json
  }).merge(public? ? {} : {
     :private_recipient_jids => [room.moderator.jid, submitter.jid],
     :bid_full => all_info.to_json
  })
end

# class Spider

def notify key, options = {}
  mq.exchange('spider', :type => :topic).publish(Marshal.dump(options), :key => key)
end



                                                                        Münchner Ruby on Rails User Group, 2010/12/2
Example: user submits a bid

XMPP Component:
# handling of the queue event: “bid.submitted”

send_msg do |xml|

  # send broadcast message

  xml.message(:to => options[:room_jid], :from => SPIDER_JID, :type => :groupchat) do
    xml.x :xmlns => NS_SPIDER_BID do
      xml.submitted options[:bid]
    end
  end

  # send private messages

  options[:private_recipient_jids] && options[:private_recipient_jids].each do |jid|
    xml.message(:to => jid, :from => SPIDER_JID, :type => :normal) do
      xml.x :xmlns => NS_SPIDER_BID do
        xml.submitted options[:bid_full], :in => options[:room_jid]
      end
    end
  end
end
                                                                        Münchner Ruby on Rails User Group, 2010/12/2
Example: user submits a bid

Client (with strophe.js):
// broadcast messages

on_broadcast_message: function (message) {

     var from = $(message).attr('from');
     var room = Strophe.getNodeFromJid(from);

     msg = $(message).find("x[xmlns='" + NS.SPIDER_BID + "'] > submitted");
	    if (msg.length > 0) {
	    	   Client.on_bid_submitted(room, JSON.parse(msg.text(), true);
     }

     // other events ...
},

// update local db, render the gui

on_bid_submitted: function (room, bid, broadcasted) {
	   Room.set_bid(room, bid, broadcasted);
	   Renderer.render_bid(room, bid);
},


                                                                         Münchner Ruby on Rails User Group, 2010/12/2
Conclusions

•   Pros:
    •   powerful toolkits for application
    •   server push for free
    •   scalability
    •   transparent for users
•   Cons:
    •   a bit admin work

                                            Münchner Ruby on Rails User Group, 2010/12/2
Demo




       Münchner Ruby on Rails User Group, 2010/12/2

Weitere ähnliche Inhalte

Was ist angesagt?

gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and ImplementationVarun Talwar
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPCGuo Jing
 
WSO2 ESB Introduction to Inbound Endpoints
WSO2 ESB Introduction to Inbound EndpointsWSO2 ESB Introduction to Inbound Endpoints
WSO2 ESB Introduction to Inbound EndpointsIsuru Udana
 
Jabber is more than instant messaging
Jabber is more than instant messagingJabber is more than instant messaging
Jabber is more than instant messagingFlorian Holzhauer
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets CocoaRobbert
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCC4Media
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and MicroservicesJonathan Gomez
 
UltraESB - an introduction
UltraESB - an introductionUltraESB - an introduction
UltraESB - an introductionAdroitLogic
 
Introduction to REST and JAX-RS
Introduction to REST and JAX-RSIntroduction to REST and JAX-RS
Introduction to REST and JAX-RSTed Pennings
 
Crash course to the Apache Camel
Crash course to the Apache CamelCrash course to the Apache Camel
Crash course to the Apache CamelHenryk Konsek
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for RubyHiroshi SHIBATA
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torqueboxrockyjaiswal
 
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...AboutYouGmbH
 
Work WIth Redis and Perl
Work WIth Redis and PerlWork WIth Redis and Perl
Work WIth Redis and PerlBrett Estrade
 

Was ist angesagt? (20)

gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and Implementation
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
WSO2 ESB Introduction to Inbound Endpoints
WSO2 ESB Introduction to Inbound EndpointsWSO2 ESB Introduction to Inbound Endpoints
WSO2 ESB Introduction to Inbound Endpoints
 
Jabber is more than instant messaging
Jabber is more than instant messagingJabber is more than instant messaging
Jabber is more than instant messaging
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
UltraESB - an introduction
UltraESB - an introductionUltraESB - an introduction
UltraESB - an introduction
 
Introduction to REST and JAX-RS
Introduction to REST and JAX-RSIntroduction to REST and JAX-RS
Introduction to REST and JAX-RS
 
Crash course to the Apache Camel
Crash course to the Apache CamelCrash course to the Apache Camel
Crash course to the Apache Camel
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torquebox
 
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 
gRPC - RPC rebirth?
gRPC - RPC rebirth?gRPC - RPC rebirth?
gRPC - RPC rebirth?
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
PHP-GTK
PHP-GTKPHP-GTK
PHP-GTK
 
Work WIth Redis and Perl
Work WIth Redis and PerlWork WIth Redis and Perl
Work WIth Redis and Perl
 

Ähnlich wie Real-time Web with Rails and XMPP

Real time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveReal time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveMickaël Rémond
 
Chat app case study - xmpp vs SIP
Chat app case study - xmpp vs SIPChat app case study - xmpp vs SIP
Chat app case study - xmpp vs SIPGenora Infotech
 
Micro on NATS - Microservices with Messaging
Micro on NATS - Microservices with MessagingMicro on NATS - Microservices with Messaging
Micro on NATS - Microservices with MessagingApcera
 
Ruby Microservices with RabbitMQ
Ruby Microservices with RabbitMQRuby Microservices with RabbitMQ
Ruby Microservices with RabbitMQZoran Majstorovic
 
Construyendo un nuevo ecosistema para comunicaciones interoperables
Construyendo un nuevo ecosistema para comunicaciones interoperablesConstruyendo un nuevo ecosistema para comunicaciones interoperables
Construyendo un nuevo ecosistema para comunicaciones interoperablesOpenDireito
 
Building a new ecosystem for interoperable communications
Building a new ecosystem for interoperable communicationsBuilding a new ecosystem for interoperable communications
Building a new ecosystem for interoperable communicationsPaloSanto Solutions
 
ROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersAtılay Mayadağ
 
Staying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with KafkaStaying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with KafkaRichard Gee
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupMickaël Rémond
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)marklucovsky
 
Ricardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devopsRicardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devopsSVDevOps
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOpsRicardo Sanchez
 
micro-ROS: bringing ROS 2 to MCUs
micro-ROS: bringing ROS 2 to MCUsmicro-ROS: bringing ROS 2 to MCUs
micro-ROS: bringing ROS 2 to MCUseProsima
 
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundrymartinlippert
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныTimur Safin
 
Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Jim Dowling
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and RailsWen-Tien Chang
 

Ähnlich wie Real-time Web with Rails and XMPP (20)

Real time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveReal time Web Application with XMPP and Wave
Real time Web Application with XMPP and Wave
 
Chat app case study - xmpp vs SIP
Chat app case study - xmpp vs SIPChat app case study - xmpp vs SIP
Chat app case study - xmpp vs SIP
 
Micro on NATS - Microservices with Messaging
Micro on NATS - Microservices with MessagingMicro on NATS - Microservices with Messaging
Micro on NATS - Microservices with Messaging
 
Node.js
Node.jsNode.js
Node.js
 
Ruby Microservices with RabbitMQ
Ruby Microservices with RabbitMQRuby Microservices with RabbitMQ
Ruby Microservices with RabbitMQ
 
Construyendo un nuevo ecosistema para comunicaciones interoperables
Construyendo un nuevo ecosistema para comunicaciones interoperablesConstruyendo un nuevo ecosistema para comunicaciones interoperables
Construyendo un nuevo ecosistema para comunicaciones interoperables
 
Building a new ecosystem for interoperable communications
Building a new ecosystem for interoperable communicationsBuilding a new ecosystem for interoperable communications
Building a new ecosystem for interoperable communications
 
ROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor Helicopters
 
Staying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with KafkaStaying on Topic - Invoke OpenFaaS functions with Kafka
Staying on Topic - Invoke OpenFaaS functions with Kafka
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF Meetup
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)
 
Ricardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devopsRicardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devops
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
 
micro-ROS: bringing ROS 2 to MCUs
micro-ROS: bringing ROS 2 to MCUsmicro-ROS: bringing ROS 2 to MCUs
micro-ROS: bringing ROS 2 to MCUs
 
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and Rails
 
Node.js scaling in highload
Node.js scaling in highloadNode.js scaling in highload
Node.js scaling in highload
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 

Kürzlich hochgeladen

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 

Kürzlich hochgeladen (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 

Real-time Web with Rails and XMPP

  • 1. Real-time Web with Rails and XMPP Münchner Ruby on Rails User Group, 2010/12/2 Li Cai (ca168168@gmail.com) founder: reliwa.de partner & ex-CTO: 16ds.com
  • 2. Motivation: 16ds.com • B2B portal and business network for the chemical industry • Market indexes for 30+ bulk chemicals based on prices submitted by diverse market players • Real-time multi-party price negotiation Münchner Ruby on Rails User Group, 2010/12/2
  • 3. Multi-party price negotiation • User self-organized • Access control based on organizational structure of the company • Customizable quotation templates for each product • Configurable admission control and protection of sensitive data (customer identities, price details, etc.) • Different negotiation modes: fixed price, bargaining, bidding, moderated bidding • Real-world near auctions by utilizing “Counting-Down- Hammer” Münchner Ruby on Rails User Group, 2010/12/2
  • 4. Server push in Rails • Polling: simple (but...) • Comet: setup external server for server push (Jetty, glassfish, cometd, ErlyComet, node.js, etc.) • FlashXML Socket: full-duplex TCP stream socket connection (extra work for firewall traversal) • XMPP/BOSH: bidirectional streams over HTTP connection • WebSockets: full-duplex over single TCP socket is being standardized by the W3C (HTML5) Münchner Ruby on Rails User Group, 2010/12/2
  • 5. XMPP • eXtensible Messaging and Presence Protocol • Data exchanged over a pair of XML streams • extensibility: very easy to add new features to the protocol • XMPP Toolkits • presence • instant messaging • Multi User Chat (XEP-0045) • Publish/Subscribe (XEP-0060) • and many more... Münchner Ruby on Rails User Group, 2010/12/2
  • 6. XMPP • BOSH (XEP-0124, XEP-0206) • long-lived bidirectional streams over HTTP connection • hide user credentials by session attachment • many XMPP servers have BOSH connection manager build-in • XMPP Component (XEP-0114) • stand-alone server process written with whatever language you like • easily extend the server with your own application logic Münchner Ruby on Rails User Group, 2010/12/2
  • 7. Extend XMPP with our new features • Build multi-party price negotiation on top of MUC • Create XMPP account for every user, while hiding the credentials by using session attachment • Create MUC-rooms on demand, and manage the member list by our application • Implement an XMPP component to interact with our application as well as the clients • Extend name space and let our application handle stuffs • Configure default settings of the XMPP server for security Münchner Ruby on Rails User Group, 2010/12/2
  • 8. Rails and XMPP Application Background Web Client HTTP Server Instances (Rails) Jobs (Rails) BOSH Conn. Message Queue Manager XMPP Server XMPP Server Component Münchner Ruby on Rails User Group, 2010/12/2
  • 9. XMPP servers • ejabberd • written in Erlang, well-known for its scalability • http://www.process-one.net/en/ejabberd/ • Openfire • written in Java, very easy to install and configure • http://www.igniterealtime.org/projects/openfire/ • Tigase • written in Java • http://www.tigase.org/ • and much more... Münchner Ruby on Rails User Group, 2010/12/2
  • 10. XMPP libraries - server side • xmpp4r • feature-rich, threaded ruby • http://home.gna.org/xmpp4r/ • blather • lightweight, DSL-style, evented ruby • http://sprsquish.github.com/blather/ • skates • lightweight, MVC-style, evented ruby • http://skates.rubyforge.org/ • strophe-ruby • ruby binding for libstrophe, can be run within a Rails-app • https://github.com/yong/stropheruby Münchner Ruby on Rails User Group, 2010/12/2
  • 11. XMPP libraries - client side • strophe.js • JavaScript • http://code.stanziq.com/strophe/ • xmpp4js • JavaScript • http://xmpp4js.sourceforge.net/ • XIFF • Flash/ActionScript • http://www.igniterealtime.org/projects/xiff/ • and many more... Münchner Ruby on Rails User Group, 2010/12/2
  • 12. Example: user submits a bid XMPP Comp. User M User A User B XMPP MUC Web App (Spider) (Moderator) (Participant) (Participant) submit bid room_jid, user_jid, [bid] groupchat:x.spider_bid.submitted [bid w. public info] update bid_list update bid_list update bid_list private? && msg:x.spider_bid.submitted [bid w. all info] update bid_list update bid_list Münchner Ruby on Rails User Group, 2010/12/2
  • 13. Example: user submits a bid Rails: # class RoomBid < ActiveRecord:Base def submit # ... authorization check and application level processing ... Spider.notify "bid.submitted", { :room_jid => room.jid, :bid => public_info.to_json }).merge(public? ? {} : { :private_recipient_jids => [room.moderator.jid, submitter.jid], :bid_full => all_info.to_json }) end # class Spider def notify key, options = {} mq.exchange('spider', :type => :topic).publish(Marshal.dump(options), :key => key) end Münchner Ruby on Rails User Group, 2010/12/2
  • 14. Example: user submits a bid XMPP Component: # handling of the queue event: “bid.submitted” send_msg do |xml| # send broadcast message xml.message(:to => options[:room_jid], :from => SPIDER_JID, :type => :groupchat) do xml.x :xmlns => NS_SPIDER_BID do xml.submitted options[:bid] end end # send private messages options[:private_recipient_jids] && options[:private_recipient_jids].each do |jid| xml.message(:to => jid, :from => SPIDER_JID, :type => :normal) do xml.x :xmlns => NS_SPIDER_BID do xml.submitted options[:bid_full], :in => options[:room_jid] end end end end Münchner Ruby on Rails User Group, 2010/12/2
  • 15. Example: user submits a bid Client (with strophe.js): // broadcast messages on_broadcast_message: function (message) { var from = $(message).attr('from'); var room = Strophe.getNodeFromJid(from); msg = $(message).find("x[xmlns='" + NS.SPIDER_BID + "'] > submitted"); if (msg.length > 0) { Client.on_bid_submitted(room, JSON.parse(msg.text(), true); } // other events ... }, // update local db, render the gui on_bid_submitted: function (room, bid, broadcasted) { Room.set_bid(room, bid, broadcasted); Renderer.render_bid(room, bid); }, Münchner Ruby on Rails User Group, 2010/12/2
  • 16. Conclusions • Pros: • powerful toolkits for application • server push for free • scalability • transparent for users • Cons: • a bit admin work Münchner Ruby on Rails User Group, 2010/12/2
  • 17. Demo Münchner Ruby on Rails User Group, 2010/12/2

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n