SlideShare uma empresa Scribd logo
1 de 210
Baixar para ler offline
Hornet q and-the-web-jud-con-2010
HornetQ & The Web
How HornetQ Embraces the Web and Its Different Forms




                   Jeff Mesnil
Who?
Who?

• Jeff Mesnil
• Software Developer
• Red Hat, JBoss
• jmesnil@{redhat|gmail}.com
• http://jmesnil.net/
• twitter: @jmesnil
What?
What?

• What is HornetQ?
What?

• What is HornetQ?
• HornetQ & The Web
What?

• What is HornetQ?
• HornetQ & The Web
• HornetQ & REST
What?

• What is HornetQ?
• HornetQ & The Web
• HornetQ & REST
• HornetQ & HTML5 WebSocket
What?

• What is HornetQ?
• HornetQ & The Web
• HornetQ & REST
• HornetQ & HTML5 WebSocket
• Pros & Cons
What?

• What is HornetQ?
• HornetQ & The Web
• HornetQ & REST
• HornetQ & HTML5 WebSocket
• Pros & Cons
• Questions?
Hornet q and-the-web-jud-con-2010
• http://jboss.org/hornetq/
• http://jboss.org/hornetq/
• JBoss community project
• http://jboss.org/hornetq/
• JBoss community project
• Open Source (Apache License 2.0)
• http://jboss.org/hornetq/
• JBoss community project
• Open Source (Apache License 2.0)
• Multi-protocol asynchronous messaging system
• http://jboss.org/hornetq/
• JBoss community project
• Open Source (Apache License 2.0)
• Multi-protocol asynchronous messaging system
• Performance
• http://jboss.org/hornetq/
• JBoss community project
• Open Source (Apache License 2.0)
• Multi-protocol asynchronous messaging system
• Performance
• Usability
Usability
Usability

• Ease of use (configuration, deployment)
Usability

• Ease of use (configuration, deployment)
• Simple API
Usability

• Ease of use (configuration, deployment)
• Simple API
• Documentation
Usability

• Ease of use (configuration, deployment)
• Simple API
• Documentation
• 90+ examples
Usability

• Ease of use (configuration, deployment)
• Simple API
• Documentation
• 90+ examples
  • A feature without documentation and example is useless
Usability

• Ease of use (configuration, deployment)
• Simple API
• Documentation
• 90+ examples
  • A feature without documentation and example is useless
• Minimal third-party dependencies
Deployment
Deployment

• Fully functional standalone messaging server
Deployment

• Fully functional standalone messaging server
• Default messaging provider for JBoss AS 6
Deployment

• Fully functional standalone messaging server
• Default messaging provider for JBoss AS 6
• Integrated with any Java EE application server using its JCA
  adaptor
Deployment

• Fully functional standalone messaging server
• Default messaging provider for JBoss AS 6
• Integrated with any Java EE application server using its JCA
  adaptor
• Use dependency-injection framework to embed it in your
  application
Generic Messaging
   Architecture
Generic Messaging
             Architecture

• Simple set of POJOs (JMS-agnostic)
Generic Messaging
             Architecture

• Simple set of POJOs (JMS-agnostic)
• No hard dependencies on JMS, JNDI, JCA
Generic Messaging
             Architecture

• Simple set of POJOs (JMS-agnostic)
• No hard dependencies on JMS, JNDI, JCA
• JMS is 1 way to use HornetQ
Generic Messaging
             Architecture

• Simple set of POJOs (JMS-agnostic)
• No hard dependencies on JMS, JNDI, JCA
• JMS is 1 way to use HornetQ
• 2 ways to use HornetQ on the Web
Generic Messaging
              Architecture

• Simple set of POJOs (JMS-agnostic)
• No hard dependencies on JMS, JNDI, JCA
• JMS is 1 way to use HornetQ
• 2 ways to use HornetQ on the Web
• Different messaging APIs / protocols in a single consistent
  messaging system
Performance
Performance

• Very high performance journal
Performance

• Very high performance journal
  • No relational database
Performance

• Very high performance journal
  • No relational database
  • Java NIO
Performance

• Very high performance journal
  • No relational database
  • Java NIO
  • JNI interface to Linux asynchronous IO
Performance

• Very high performance journal
  • No relational database
  • Java NIO
  • JNI interface to Linux asynchronous IO
• Very fast transport layer
Performance

• Very high performance journal
  • No relational database
  • Java NIO
  • JNI interface to Linux asynchronous IO
• Very fast transport layer
  • Netty
Performance

• Very high performance journal
  • No relational database
  • Java NIO
  • JNI interface to Linux asynchronous IO
• Very fast transport layer
  • Netty
• Don’t take my word for it!
Performance

• Very high performance journal
  • No relational database
  • Java NIO
  • JNI interface to Linux asynchronous IO
• Very fast transport layer
  • Netty
• Don’t take my word for it!
  • http://www.spec.org/jms2007/results/jms2007.html
Supported Protocols
Supported Protocols


• Core
• JMS
• STOMP
• REST
HornetQ Core Protocol
HornetQ Core Protocol

• Java
HornetQ Core Protocol

• Java
• Optimized
HornetQ Core Protocol

• Java
• Optimized
• Send messages to an address
HornetQ Core Protocol

• Java
• Optimized
• Send messages to an address
• Consume messages from a queue
HornetQ Core Protocol

• Java
• Optimized
• Send messages to an address
• Consume messages from a queue
• Bindings between addresses and queues and queues and
  consumers define the messaging model
HornetQ Core
HornetQ Core
HornetQ Core

 Address
HornetQ Core

Producer    Address
HornetQ Core

           message
Producer              Address
            sends
HornetQ Core

           message
Producer              Address
            sends




                                    Consumer
HornetQ Core

           message
Producer              Address
            sends




                                Queue   Consumer
HornetQ Core

           message
Producer              Address
            sends




                                Queue   Consumer
HornetQ Core

           message
Producer              Address
            sends




                                        message

                                Queue             Consumer
HornetQ Core

           message
Producer              Address
            sends



                                ?
                                        message

                                Queue             Consumer
JMS API
JMS API


• Java / Java EE
JMS API


• Java / Java EE
• Point-to-Point (queues)
  • 1 producer - 1 consumer
JMS API


• Java / Java EE
• Point-to-Point (queues)
  • 1 producer - 1 consumer
• Publish/Subscribe (topics)
  • 1 producer - N consumers
JMS Queue
JMS Queue

Address
JMS Queue

Address




          Queue
JMS Queue

Address




          Queue
JMS Queue

Address




          Queue   Consumer 1



                  Consumer 2
JMS Queue

Address




          Queue   Consumer 1



                  Consumer 2
JMS Queue

Producer   Address




                     Queue   Consumer 1



                             Consumer 2
JMS Queue

           message
Producer             Address
            sends




                               Queue   Consumer 1



                                       Consumer 2
JMS Queue

           message
Producer             Address
            sends




                                       message
                               Queue             Consumer 1



                                                 Consumer 2
JMS Queue

           message
Producer             Address
            sends




                               Queue   Consumer 1



                                       Consumer 2
JMS Queue

           message
Producer             Address
            sends




                               Queue             Consumer 1



                                                 Consumer 2
                                       message
JMS Topic
JMS Topic

Producer
JMS Topic

Producer




                       Consumer 1



                       Consumer 2
JMS Topic

Producer    Address




                       Consumer 1



                       Consumer 2
JMS Topic

Producer    Address




                      Queue   Consumer 1



                              Consumer 2
JMS Topic

Producer    Address




                      Queue   Consumer 1



                      Queue   Consumer 2
JMS Topic

Producer    Address




                      Queue   Consumer 1



                      Queue   Consumer 2
JMS Topic

           message
Producer              Address
            sends




                                Queue   Consumer 1



                                Queue   Consumer 2
JMS Topic

           message
Producer              Address
            sends




                                Queue   Consumer 1



                                Queue   Consumer 2
JMS Topic

           message
Producer              Address
            sends




                                        message
                                Queue             Consumer 1



                                Queue             Consumer 2
                                        message
JMS Models
JMS Models

• JMS Queue
  • 1 address - 1 queue binding
  • Many consumers for the queue
JMS Models

• JMS Queue
  • 1 address - 1 queue binding
  • Many consumers for the queue
• JMS Topic
  • 1 address - many queues binding
  • 1 single consumer per queue
STOMP
STOMP


• http://stomp.codehaus.org/
STOMP


• http://stomp.codehaus.org/
• Text-orientated messaging protocol
STOMP


• http://stomp.codehaus.org/
• Text-orientated messaging protocol
• Interoperability
STOMP


• http://stomp.codehaus.org/
• Text-orientated messaging protocol
• Interoperability
• Clients for many languages
STOMP


• http://stomp.codehaus.org/
• Text-orientated messaging protocol
• Interoperability
• Clients for many languages
• Simple and flexible (headers, ack, transactions)
STOMP
$ telnet localhost 61613
CONNECT
login: jmesnil
passcode: mypassword
^@

SEND
destination:/queue/myqueue

this is my message body
^@
REST
REST



• HTTP-Based RESTful API
• More on that in a minute...
Many Other Features
Many Other Features

• Clustering, HA, Failover
• Bridges and Diverts
• Management (JMX, JMS)
• Dead Letters, Expiration
• ...
• http://community.jboss.org/wiki/HornetQFeatures
But
But


HornetQ & The Web
HornetQ & The Web
HornetQ & The Web
• Web is everywhere
HornetQ & The Web
• Web is everywhere
• Cloud Computing
HornetQ & The Web
• Web is everywhere
• Cloud Computing
• Integration
  • Entreprise environment
  • Heterogenous platforms
HornetQ & The Web
• Web is everywhere
• Cloud Computing
• Integration
  • Entreprise environment
  • Heterogenous platforms
• End-user applications
  • Web Browsers
  • RIA
HornetQ & The Web
• Web is everywhere
• Cloud Computing
• Integration
  • Entreprise environment
  • Heterogenous platforms
• End-user applications
  • Web Browsers
  • RIA
• More and more web-based applications needs messaging
Messaging and the Web
Messaging and the Web


• Asynchronous
• Loosely-coupled
• Distributed
HornetQ and the Web
HornetQ and the Web


• HornetQ Core/JMS over HTTP
HornetQ and the Web


• HornetQ Core/JMS over HTTP
• REST API over HTTP
HornetQ and the Web


• HornetQ Core/JMS over HTTP
• REST API over HTTP
• STOMP over HTML5 WebSocket
HornetQ Over HTTP
HornetQ Over HTTP


• Use HTTP instead of TCP as the transport layer
• Work around firewalls
• Not Web-friendly
  • Requires HornetQ Java client library
  • HornetQ Core wireformat encoded
Hornet q and-the-web-jud-con-2010
HornetQ REST API
HornetQ REST API


• RESTful API to do messaging over HTTP
HornetQ REST API


• RESTful API to do messaging over HTTP
• http://en.wikipedia.org/wiki/Representational_State_Transfer
HornetQ REST API


• RESTful API to do messaging over HTTP
• http://en.wikipedia.org/wiki/Representational_State_Transfer
• Based on RESTEasy
RESTEasy
RESTEasy
•   http://www.jboss.org/resteasy/
•   JBoss community project
•   Open Source (Apache license 2.0)
•   Fully certified JAX-RS implementation
•   Portable to any application server/web container
•   Rich set of providers (XML, JSON, YAML, Atom, etc.)
•   JAXB marshalling into XML, JSON, etc.
•   Wrappers for maps, arrays, lists, and sets of JAXB Objects.
•   GZIP content-encoding
•   Rich interceptor model
•   EJB, Seam, Guice, Spring, and Spring MVC integration
TomTom Work [1/2]
TomTom Work [1/2]

• http://www.tomtomwork.com/en/products/what.xml
• Fleet management solution
• Mobile navigation system connected to the web-based
  management and communication service
• Two-way communication and navigation
  • Vehicles send their position and other infos
  • Receive incoming text messages from TomTom servers
TomTom Work [2/2]
TomTom Work [2/2]

• GPS devices in the vehicles (GPRS / TCP)
• TomTom data center
  • JMS
  • DB
  • GUI + REST Web Services
• 120K+ devices
• 150K JMS messages/min at peak time (2 peaks every day)
• 120M JMS messages/day
Demo
Demo

• Application to track the location of users
Demo

• Application to track the location of users
  • Users will use their mobile phones to broadcast their
    position (REST API)
Demo

• Application to track the location of users
  • Users will use their mobile phones to broadcast their
    position (REST API)
  • Web application to monitor the users’ positions (STOMP
    over HTML5 WebSocket)
Demo

• Application to track the location of users
  • Users will use their mobile phones to broadcast their
    position (REST API)
  • Web application to monitor the users’ positions (STOMP
    over HTML5 WebSocket)
  • Application to keep a log of everybody’s moves (JMS)
JMS Topic




            JMS Monitoring Application
HornetQ Server Configuration
hornetq-jms.xml

<configuration>
    <topic name="trackers">
      <entry name="/topic/trackers" />
   </topic>
</configuration>

hornetq-configuration.xml

<acceptor name="jms">
   <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</
factory-class>
</acceptor>
<acceptor name="websockets">
   <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</
factory-class>
   <param key="protocol" value="stomp_ws" />
   <param key="port" value="61614" />
</acceptor>
RESTEasy Configuration
WEB-INF/web.xml

<listener>
   <listener-
class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-
class>
</listener>
<listener>
   <listener-class>org.hornetq.rest.integration.HornetqBootstrapListener</
listener-class>
</listener>
<listener>
  <listener-class>org.hornetq.rest.integration.RestMessagingBootstrapListener</
listener-class>
</listener>

...

<context-param>
  <param-name>rest.messaging.config.file</param-name>
  <param-value>rest-config.xml</param-value>
</context-param>
RESTEasy Configuration
rest-config.xml

<rest-messaging>
  <server-in-vm-id>0</server-in-vm-id>
  <use-link-headers>false</use-link-headers>
  <default-durable-send>false</default-durable-send>
  <dups-ok>true</dups-ok>
  <topic-push-store-dir>topic-push-store</topic-push-store-dir>
  <queue-push-store-dir>queue-push-store</queue-push-store-dir>
  <producer-session-pool-size>10</producer-session-pool-size>
  <session-timeout-task-interval>1</session-timeout-task-interval>
  <consumer-session-timeout-seconds>300</consumer-session-timeout-
seconds>
  <consumer-window-size>-1</consumer-window-size>
</rest-messaging>
Hornet q and-the-web-jud-con-2010
Demo
HornetQ REST API
HornetQ REST API
• RESTful messaging specification
  • http://www.jboss.org/reststar/specifications/messaging.html
HornetQ REST API
• RESTful messaging specification
  • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
HornetQ REST API
• RESTful messaging specification
   • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
• Usable by any programming language that has an HTTP client
  library
HornetQ REST API
• RESTful messaging specification
   • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
• Usable by any programming language that has an HTTP client
  library
• Zero client footprint (no libraries to download, install and deploy)
HornetQ REST API
• RESTful messaging specification
   • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
• Usable by any programming language that has an HTTP client
  library
• Zero client footprint (no libraries to download, install and deploy)
• No envelope (à la SOAP) or feed (à la Atom) format
  requirements
   • the HTTP request/response is the message
HornetQ REST API
• RESTful messaging specification
   • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
• Usable by any programming language that has an HTTP client
  library
• Zero client footprint (no libraries to download, install and deploy)
• No envelope (à la SOAP) or feed (à la Atom) format
  requirements
   • the HTTP request/response is the message
• Ligthweight interoperability
HornetQ REST API
• RESTful messaging specification
   • http://www.jboss.org/reststar/specifications/messaging.html
• Simple REST/HTTP interface to access HornetQ
• Usable by any programming language that has an HTTP client
  library
• Zero client footprint (no libraries to download, install and deploy)
• No envelope (à la SOAP) or feed (à la Atom) format
  requirements
   • the HTTP request/response is the message
• Ligthweight interoperability
• Pub/Sub (topics) and Point-to-point (queues)
HornetQ REST API
HornetQ REST API


• Follow the headers
HornetQ REST API


• Follow the headers
• Duplicate Detection
HornetQ REST API


• Follow the headers
• Duplicate Detection
• Persistent messages ?durable=true
Send a Message [1/2]

=> Query the resource URL

HEAD /topics/jms.topic.trackers HTTP/1.1
Host: example.com

--- Response ---
HTTP/1.1 200 Ok
msg-create: http://example.com/topics/jms.topic.trackers/create
msg-create-with-id: http://example.com/topics/jms.topic.trackers/
create/{id}
Send a Message [2/2]
POST /topics/jms.topic.trackers/create
Host: example.com
Content-Type: application/json

{
    "alias": "jmesnil",
    "position": {
        "coords": {
            "longitude": 65.735344446666666,
            "latitude": 35.198200083333326
        },
        "timestamp": 1285943662645
    }
}

--- Response ---
HTTP/1.1 201 Created
msg-create-next: http://example.com/topics/jms.topic.trackers/create/
002
Receive a Message - Pull [1/4]

=> query the resource URL

HEAD /topics/jms.topic.trackers HTTP/1.1
Host: example.com

--- Response ---
HTTP/1.1 200 Ok
msg-create: http://example.com/topics/jms.topic.trackers/create
msg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/
pull-subscriptions
msg-push-subscriptions: http://example.com/topics/jms.topic.trackers/
push-subscriptions
Receive a Message - Pull [2/4]

=> create a subscription by doing an empty POST on the msg-pull-subscriptions URL

POST /topics/jms.topic.trackers/pull-subscriptions HTTP/1.1
Host: example.com

--- Response ---
HTTP/1.1 201 Created
Location: http://example.com/topics/jms.topic.trackers/pull-
subscriptions/auto-ack/222
msg-consume-next: http://example.com/topics/jms.topic.trackers/pull-
subscriptions/auto-ack/222/consume-next-1
Receive a Message - Pull [3/4]
=> consume the message by POSTing on the subscription

POST /topics/jms.topic.trackers/pull-subscriptions/auto-ack/222/consume-next-1
Host: example.com

--- Response ---
HTTP/1.1 200 Ok
Content-Type: application/json
msg-consume-next: http://example.com/topics/jms.topic.trackers/pull-
subscriptions/auto-ack/222/consume-next-2

{
    "alias": "jmesnil",
    "position": {
        "coords": {
            "longitude": 65.735344446666666,
            "latitude": 35.198200083333326,
            ...
        },
        "timestamp": 1285943662645
    }
}
Receive a Message - Pull [4/4]

 => if there is no message to consume, will return 503

POST /queues/jms.queue.bar/pull-consumers/consume-next-2
Host: example.com

--- Response ---
Http/1.1 503 Service Unavailable
Retry-After: 5
msg-consume-next: http://example.com/queues/jms.queue.bar/pull-
consumers/333/consume-next-2
Receive a Message - Push[1/2]

=> query the Topic resource URL

HEAD /topics/jms.topic.trackers HTTP/1.1
Host: example.com

--- Response ---
HTTP/1.1 200 Ok
msg-create: http://example.com/topics/jms.topic.trackers/create
msg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/
pull-subscriptions
msg-push-subscriptions: http://example.com/topics/jms.topic.trackers/
push-subscriptions
Receive a Message - Push[2/2]
=> create a push subscription

POST /topics/jms.topic.trackers/push-subscriptions
Host: example.com
Content-Type: application/xml

<push-topic-registration>
   <link rel="template" href="http://somewhere.com/resources/{id}/
messages" method="POST"/>
</push-topic registration>

--- Response ---
HTTP/1.1 201 Created
Location: http://example.com/topics/jms.topic.trackers/push-
subscriptions/1-333-1212

=> new messages will be POSTed to http://somewhere.com/resources/
{id}/messages URL
Create a Destination

POST /topics
Host: example.com
Content-Type: application/hornetq.jms.topic+xml

<topic name="testTopic" />

--- Response ---
HTTP/1.1 201 Created
Location: http://example.com/topics/jms.topic.testTopic
HTML5
HTML5


• http://www.w3.org/TR/html5/
HTML5


• http://www.w3.org/TR/html5/
• Revision of HTML markup language
HTML5


• http://www.w3.org/TR/html5/
• Revision of HTML markup language
• JavaScript APIs
HTML5


• http://www.w3.org/TR/html5/
• Revision of HTML markup language
• JavaScript APIs
  • canvas, geolocation, video, audio, etc.
HTML5


• http://www.w3.org/TR/html5/
• Revision of HTML markup language
• JavaScript APIs
  • canvas, geolocation, video, audio, etc.
  • WebSocket!
HTML5 WebSocket
HTML5 WebSocket

• «TCP for the Web»...
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
• same-origin security model
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
• same-origin security model
• JavaScript API in the browser
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
• same-origin security model
• JavaScript API in the browser
  • http://dev.w3.org/html5/websockets/
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
• same-origin security model
• JavaScript API in the browser
  • http://dev.w3.org/html5/websockets/
• WebSocket protocol on the server
HTML5 WebSocket

• «TCP for the Web»...
• bidirectional communication between the browser and the
  web server
• same-origin security model
• JavaScript API in the browser
  • http://dev.w3.org/html5/websockets/
• WebSocket protocol on the server
  • http://tools.ietf.org/html/draft-hixie-
    thewebsocketprotocol-76
STOMP Over WebSocket
STOMP Over WebSocket
• WebSocket instead of TCP
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
• JavaScript libraries to send and receive STOMP messages
  • http://jmesnil.net/stomp-websocket/doc/
  • http://github.com/krukow/stomple
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
• JavaScript libraries to send and receive STOMP messages
  • http://jmesnil.net/stomp-websocket/doc/
  • http://github.com/krukow/stomple
• ActiveMQ, RabbitMQ(?)
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
• JavaScript libraries to send and receive STOMP messages
  • http://jmesnil.net/stomp-websocket/doc/
  • http://github.com/krukow/stomple
• ActiveMQ, RabbitMQ(?)
• Talks about adding it to STOMP 2.0 specification
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
• JavaScript libraries to send and receive STOMP messages
  • http://jmesnil.net/stomp-websocket/doc/
  • http://github.com/krukow/stomple
• ActiveMQ, RabbitMQ(?)
• Talks about adding it to STOMP 2.0 specification
• Work with text only (no bytes)
STOMP Over WebSocket
• WebSocket instead of TCP
• STOMP as the messaging protocol
• JavaScript libraries to send and receive STOMP messages
  • http://jmesnil.net/stomp-websocket/doc/
  • http://github.com/krukow/stomple
• ActiveMQ, RabbitMQ(?)
• Talks about adding it to STOMP 2.0 specification
• Work with text only (no bytes)
• Receive message by push-only
Hornet q and-the-web-jud-con-2010
Demo
STOMP Over WebSocket
STOMP Over WebSocket


• JavaScript-based
STOMP Over WebSocket


• JavaScript-based
• Looks like other STOMP clients
STOMP Over WebSocket


• JavaScript-based
• Looks like other STOMP clients
• Send and receive text-only messages
Create a Client
// create a client
var url = "ws://example.com:61614/stomp";
var client = Stomp.client(url);

// connect to the STOMP server
client.connect(login, passcode, function() {
    // called back after the client is connected
    // and authenticated to the server
});

...

// disconnect from the server
client.disconnect();
Send and Receive Messages
// send a message
var tracker = ...; // retrieved from Geolocation API
client.send("jms.topic.trackers", {}, JSON.stringify(tracker));


// subscribe to a destination
var sub_id = client.subscribe("jms.topic.trackers", function(message)
{
    // called back everytime a message is sent to the destination
    var tracker = JSON.parse(message.body);
    ...
});

// unsubscribe from a destination
client.unsubscribe(sub_id);
REST or WebSocket?
REST or WebSocket?

• Different usage and timeline
REST or WebSocket?

• Different usage and timeline
• WebSocket
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
  • (+) push data from the server to the browser
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
  • (+) push data from the server to the browser
  • (-) Limited support now, will likely expand
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
  • (+) push data from the server to the browser
  • (-) Limited support now, will likely expand
• REST
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
  • (+) push data from the server to the browser
  • (-) Limited support now, will likely expand
• REST
  • (+) Works everywhere now
REST or WebSocket?

• Different usage and timeline
• WebSocket
  • (+) TCP-like
  • (+) push data from the server to the browser
  • (-) Limited support now, will likely expand
• REST
  • (+) Works everywhere now
  • (-) No push messages in the browser
Conclusion
Conclusion


• Different ways to do messaging on the Web
Conclusion


• Different ways to do messaging on the Web
• Integrate with the whole Java / Java EE ecosystem
Conclusion


• Different ways to do messaging on the Web
• Integrate with the whole Java / Java EE ecosystem
• Embraces Web principles (REST)
Conclusion


• Different ways to do messaging on the Web
• Integrate with the whole Java / Java EE ecosystem
• Embraces Web principles (REST)
• Integration & interoperability
Conclusion


• Different ways to do messaging on the Web
• Integrate with the whole Java / Java EE ecosystem
• Embraces Web principles (REST)
• Integration & interoperability
• ... Performance(?)
Demo Source



• http://github.com/jmesnil/hornetq/tree/judcon
Questions?
Hornet q and-the-web-jud-con-2010
Danke Schön!

Mais conteúdo relacionado

Semelhante a Hornet q and-the-web-jud-con-2010

Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]Ryan Cuprak
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache KafkaBen Stopford
 
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...Erik Onnen
 
The Future of Cross-Platform is Native
The Future of Cross-Platform is NativeThe Future of Cross-Platform is Native
The Future of Cross-Platform is NativeJustin Mancinelli
 
Connecting applicationswitha mq
Connecting applicationswitha mqConnecting applicationswitha mq
Connecting applicationswitha mqRob Davies
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmqSelasie Hanson
 
Introduction tojms
Introduction tojmsIntroduction tojms
Introduction tojmsMaya Swamy
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqdevObjective
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqColdFusionConference
 
GWT Jug Stuttgart
GWT Jug StuttgartGWT Jug Stuttgart
GWT Jug Stuttgarthbraun
 
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...HostedbyConfluent
 
Distributed messaging with Apache Kafka
Distributed messaging with Apache KafkaDistributed messaging with Apache Kafka
Distributed messaging with Apache KafkaSaumitra Srivastav
 
A detailed Tibco EMS presentation
A detailed Tibco EMS presentationA detailed Tibco EMS presentation
A detailed Tibco EMS presentationCblsolutions.com
 
From a kafkaesque story to The Promised Land
From a kafkaesque story to The Promised LandFrom a kafkaesque story to The Promised Land
From a kafkaesque story to The Promised LandRan Silberman
 
JUDCon London 2011 - Elastic SOA on the Cloud, Steve Millidge
JUDCon London 2011 - Elastic SOA on the Cloud, Steve MillidgeJUDCon London 2011 - Elastic SOA on the Cloud, Steve Millidge
JUDCon London 2011 - Elastic SOA on the Cloud, Steve MillidgeC2B2 Consulting
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows AzureDamir Dobric
 

Semelhante a Hornet q and-the-web-jud-con-2010 (20)

Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache Kafka
 
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...
Data Models and Consumer Idioms Using Apache Kafka for Continuous Data Stream...
 
The Future of Cross-Platform is Native
The Future of Cross-Platform is NativeThe Future of Cross-Platform is Native
The Future of Cross-Platform is Native
 
Connecting applicationswitha mq
Connecting applicationswitha mqConnecting applicationswitha mq
Connecting applicationswitha mq
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
 
Introduction tojms
Introduction tojmsIntroduction tojms
Introduction tojms
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
GWT Jug Stuttgart
GWT Jug StuttgartGWT Jug Stuttgart
GWT Jug Stuttgart
 
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...
Fan-in Flames: Scaling Kafka to Millions of Producers With Ryanne Dolan | Cur...
 
Distributed messaging with Apache Kafka
Distributed messaging with Apache KafkaDistributed messaging with Apache Kafka
Distributed messaging with Apache Kafka
 
A detailed Tibco EMS presentation
A detailed Tibco EMS presentationA detailed Tibco EMS presentation
A detailed Tibco EMS presentation
 
From a kafkaesque story to The Promised Land
From a kafkaesque story to The Promised LandFrom a kafkaesque story to The Promised Land
From a kafkaesque story to The Promised Land
 
Babel.pptx
Babel.pptxBabel.pptx
Babel.pptx
 
Messaging in Java
Messaging in JavaMessaging in Java
Messaging in Java
 
JUDCon London 2011 - Elastic SOA on the Cloud, Steve Millidge
JUDCon London 2011 - Elastic SOA on the Cloud, Steve MillidgeJUDCon London 2011 - Elastic SOA on the Cloud, Steve Millidge
JUDCon London 2011 - Elastic SOA on the Cloud, Steve Millidge
 
Fabric8 mq
Fabric8 mqFabric8 mq
Fabric8 mq
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows Azure
 

Hornet q and-the-web-jud-con-2010

  • 2. HornetQ & The Web How HornetQ Embraces the Web and Its Different Forms Jeff Mesnil
  • 4. Who? • Jeff Mesnil • Software Developer • Red Hat, JBoss • jmesnil@{redhat|gmail}.com • http://jmesnil.net/ • twitter: @jmesnil
  • 6. What? • What is HornetQ?
  • 7. What? • What is HornetQ? • HornetQ & The Web
  • 8. What? • What is HornetQ? • HornetQ & The Web • HornetQ & REST
  • 9. What? • What is HornetQ? • HornetQ & The Web • HornetQ & REST • HornetQ & HTML5 WebSocket
  • 10. What? • What is HornetQ? • HornetQ & The Web • HornetQ & REST • HornetQ & HTML5 WebSocket • Pros & Cons
  • 11. What? • What is HornetQ? • HornetQ & The Web • HornetQ & REST • HornetQ & HTML5 WebSocket • Pros & Cons • Questions?
  • 15. • http://jboss.org/hornetq/ • JBoss community project • Open Source (Apache License 2.0)
  • 16. • http://jboss.org/hornetq/ • JBoss community project • Open Source (Apache License 2.0) • Multi-protocol asynchronous messaging system
  • 17. • http://jboss.org/hornetq/ • JBoss community project • Open Source (Apache License 2.0) • Multi-protocol asynchronous messaging system • Performance
  • 18. • http://jboss.org/hornetq/ • JBoss community project • Open Source (Apache License 2.0) • Multi-protocol asynchronous messaging system • Performance • Usability
  • 20. Usability • Ease of use (configuration, deployment)
  • 21. Usability • Ease of use (configuration, deployment) • Simple API
  • 22. Usability • Ease of use (configuration, deployment) • Simple API • Documentation
  • 23. Usability • Ease of use (configuration, deployment) • Simple API • Documentation • 90+ examples
  • 24. Usability • Ease of use (configuration, deployment) • Simple API • Documentation • 90+ examples • A feature without documentation and example is useless
  • 25. Usability • Ease of use (configuration, deployment) • Simple API • Documentation • 90+ examples • A feature without documentation and example is useless • Minimal third-party dependencies
  • 27. Deployment • Fully functional standalone messaging server
  • 28. Deployment • Fully functional standalone messaging server • Default messaging provider for JBoss AS 6
  • 29. Deployment • Fully functional standalone messaging server • Default messaging provider for JBoss AS 6 • Integrated with any Java EE application server using its JCA adaptor
  • 30. Deployment • Fully functional standalone messaging server • Default messaging provider for JBoss AS 6 • Integrated with any Java EE application server using its JCA adaptor • Use dependency-injection framework to embed it in your application
  • 31. Generic Messaging Architecture
  • 32. Generic Messaging Architecture • Simple set of POJOs (JMS-agnostic)
  • 33. Generic Messaging Architecture • Simple set of POJOs (JMS-agnostic) • No hard dependencies on JMS, JNDI, JCA
  • 34. Generic Messaging Architecture • Simple set of POJOs (JMS-agnostic) • No hard dependencies on JMS, JNDI, JCA • JMS is 1 way to use HornetQ
  • 35. Generic Messaging Architecture • Simple set of POJOs (JMS-agnostic) • No hard dependencies on JMS, JNDI, JCA • JMS is 1 way to use HornetQ • 2 ways to use HornetQ on the Web
  • 36. Generic Messaging Architecture • Simple set of POJOs (JMS-agnostic) • No hard dependencies on JMS, JNDI, JCA • JMS is 1 way to use HornetQ • 2 ways to use HornetQ on the Web • Different messaging APIs / protocols in a single consistent messaging system
  • 38. Performance • Very high performance journal
  • 39. Performance • Very high performance journal • No relational database
  • 40. Performance • Very high performance journal • No relational database • Java NIO
  • 41. Performance • Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO
  • 42. Performance • Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO • Very fast transport layer
  • 43. Performance • Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO • Very fast transport layer • Netty
  • 44. Performance • Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO • Very fast transport layer • Netty • Don’t take my word for it!
  • 45. Performance • Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO • Very fast transport layer • Netty • Don’t take my word for it! • http://www.spec.org/jms2007/results/jms2007.html
  • 47. Supported Protocols • Core • JMS • STOMP • REST
  • 50. HornetQ Core Protocol • Java • Optimized
  • 51. HornetQ Core Protocol • Java • Optimized • Send messages to an address
  • 52. HornetQ Core Protocol • Java • Optimized • Send messages to an address • Consume messages from a queue
  • 53. HornetQ Core Protocol • Java • Optimized • Send messages to an address • Consume messages from a queue • Bindings between addresses and queues and queues and consumers define the messaging model
  • 58. HornetQ Core message Producer Address sends
  • 59. HornetQ Core message Producer Address sends Consumer
  • 60. HornetQ Core message Producer Address sends Queue Consumer
  • 61. HornetQ Core message Producer Address sends Queue Consumer
  • 62. HornetQ Core message Producer Address sends message Queue Consumer
  • 63. HornetQ Core message Producer Address sends ? message Queue Consumer
  • 65. JMS API • Java / Java EE
  • 66. JMS API • Java / Java EE • Point-to-Point (queues) • 1 producer - 1 consumer
  • 67. JMS API • Java / Java EE • Point-to-Point (queues) • 1 producer - 1 consumer • Publish/Subscribe (topics) • 1 producer - N consumers
  • 72. JMS Queue Address Queue Consumer 1 Consumer 2
  • 73. JMS Queue Address Queue Consumer 1 Consumer 2
  • 74. JMS Queue Producer Address Queue Consumer 1 Consumer 2
  • 75. JMS Queue message Producer Address sends Queue Consumer 1 Consumer 2
  • 76. JMS Queue message Producer Address sends message Queue Consumer 1 Consumer 2
  • 77. JMS Queue message Producer Address sends Queue Consumer 1 Consumer 2
  • 78. JMS Queue message Producer Address sends Queue Consumer 1 Consumer 2 message
  • 81. JMS Topic Producer Consumer 1 Consumer 2
  • 82. JMS Topic Producer Address Consumer 1 Consumer 2
  • 83. JMS Topic Producer Address Queue Consumer 1 Consumer 2
  • 84. JMS Topic Producer Address Queue Consumer 1 Queue Consumer 2
  • 85. JMS Topic Producer Address Queue Consumer 1 Queue Consumer 2
  • 86. JMS Topic message Producer Address sends Queue Consumer 1 Queue Consumer 2
  • 87. JMS Topic message Producer Address sends Queue Consumer 1 Queue Consumer 2
  • 88. JMS Topic message Producer Address sends message Queue Consumer 1 Queue Consumer 2 message
  • 90. JMS Models • JMS Queue • 1 address - 1 queue binding • Many consumers for the queue
  • 91. JMS Models • JMS Queue • 1 address - 1 queue binding • Many consumers for the queue • JMS Topic • 1 address - many queues binding • 1 single consumer per queue
  • 92. STOMP
  • 95. STOMP • http://stomp.codehaus.org/ • Text-orientated messaging protocol • Interoperability
  • 96. STOMP • http://stomp.codehaus.org/ • Text-orientated messaging protocol • Interoperability • Clients for many languages
  • 97. STOMP • http://stomp.codehaus.org/ • Text-orientated messaging protocol • Interoperability • Clients for many languages • Simple and flexible (headers, ack, transactions)
  • 98. STOMP $ telnet localhost 61613 CONNECT login: jmesnil passcode: mypassword ^@ SEND destination:/queue/myqueue this is my message body ^@
  • 99. REST
  • 100. REST • HTTP-Based RESTful API • More on that in a minute...
  • 102. Many Other Features • Clustering, HA, Failover • Bridges and Diverts • Management (JMX, JMS) • Dead Letters, Expiration • ... • http://community.jboss.org/wiki/HornetQFeatures
  • 103. But
  • 106. HornetQ & The Web • Web is everywhere
  • 107. HornetQ & The Web • Web is everywhere • Cloud Computing
  • 108. HornetQ & The Web • Web is everywhere • Cloud Computing • Integration • Entreprise environment • Heterogenous platforms
  • 109. HornetQ & The Web • Web is everywhere • Cloud Computing • Integration • Entreprise environment • Heterogenous platforms • End-user applications • Web Browsers • RIA
  • 110. HornetQ & The Web • Web is everywhere • Cloud Computing • Integration • Entreprise environment • Heterogenous platforms • End-user applications • Web Browsers • RIA • More and more web-based applications needs messaging
  • 112. Messaging and the Web • Asynchronous • Loosely-coupled • Distributed
  • 114. HornetQ and the Web • HornetQ Core/JMS over HTTP
  • 115. HornetQ and the Web • HornetQ Core/JMS over HTTP • REST API over HTTP
  • 116. HornetQ and the Web • HornetQ Core/JMS over HTTP • REST API over HTTP • STOMP over HTML5 WebSocket
  • 118. HornetQ Over HTTP • Use HTTP instead of TCP as the transport layer • Work around firewalls • Not Web-friendly • Requires HornetQ Java client library • HornetQ Core wireformat encoded
  • 121. HornetQ REST API • RESTful API to do messaging over HTTP
  • 122. HornetQ REST API • RESTful API to do messaging over HTTP • http://en.wikipedia.org/wiki/Representational_State_Transfer
  • 123. HornetQ REST API • RESTful API to do messaging over HTTP • http://en.wikipedia.org/wiki/Representational_State_Transfer • Based on RESTEasy
  • 125. RESTEasy • http://www.jboss.org/resteasy/ • JBoss community project • Open Source (Apache license 2.0) • Fully certified JAX-RS implementation • Portable to any application server/web container • Rich set of providers (XML, JSON, YAML, Atom, etc.) • JAXB marshalling into XML, JSON, etc. • Wrappers for maps, arrays, lists, and sets of JAXB Objects. • GZIP content-encoding • Rich interceptor model • EJB, Seam, Guice, Spring, and Spring MVC integration
  • 127. TomTom Work [1/2] • http://www.tomtomwork.com/en/products/what.xml • Fleet management solution • Mobile navigation system connected to the web-based management and communication service • Two-way communication and navigation • Vehicles send their position and other infos • Receive incoming text messages from TomTom servers
  • 129. TomTom Work [2/2] • GPS devices in the vehicles (GPRS / TCP) • TomTom data center • JMS • DB • GUI + REST Web Services • 120K+ devices • 150K JMS messages/min at peak time (2 peaks every day) • 120M JMS messages/day
  • 130. Demo
  • 131. Demo • Application to track the location of users
  • 132. Demo • Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API)
  • 133. Demo • Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API) • Web application to monitor the users’ positions (STOMP over HTML5 WebSocket)
  • 134. Demo • Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API) • Web application to monitor the users’ positions (STOMP over HTML5 WebSocket) • Application to keep a log of everybody’s moves (JMS)
  • 135. JMS Topic JMS Monitoring Application
  • 136. HornetQ Server Configuration hornetq-jms.xml <configuration> <topic name="trackers"> <entry name="/topic/trackers" /> </topic> </configuration> hornetq-configuration.xml <acceptor name="jms"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</ factory-class> </acceptor> <acceptor name="websockets"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</ factory-class> <param key="protocol" value="stomp_ws" /> <param key="port" value="61614" /> </acceptor>
  • 137. RESTEasy Configuration WEB-INF/web.xml <listener> <listener- class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener- class> </listener> <listener> <listener-class>org.hornetq.rest.integration.HornetqBootstrapListener</ listener-class> </listener> <listener> <listener-class>org.hornetq.rest.integration.RestMessagingBootstrapListener</ listener-class> </listener> ... <context-param> <param-name>rest.messaging.config.file</param-name> <param-value>rest-config.xml</param-value> </context-param>
  • 138. RESTEasy Configuration rest-config.xml <rest-messaging> <server-in-vm-id>0</server-in-vm-id> <use-link-headers>false</use-link-headers> <default-durable-send>false</default-durable-send> <dups-ok>true</dups-ok> <topic-push-store-dir>topic-push-store</topic-push-store-dir> <queue-push-store-dir>queue-push-store</queue-push-store-dir> <producer-session-pool-size>10</producer-session-pool-size> <session-timeout-task-interval>1</session-timeout-task-interval> <consumer-session-timeout-seconds>300</consumer-session-timeout- seconds> <consumer-window-size>-1</consumer-window-size> </rest-messaging>
  • 140. Demo
  • 142. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html
  • 143. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ
  • 144. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ • Usable by any programming language that has an HTTP client library
  • 145. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ • Usable by any programming language that has an HTTP client library • Zero client footprint (no libraries to download, install and deploy)
  • 146. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ • Usable by any programming language that has an HTTP client library • Zero client footprint (no libraries to download, install and deploy) • No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message
  • 147. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ • Usable by any programming language that has an HTTP client library • Zero client footprint (no libraries to download, install and deploy) • No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message • Ligthweight interoperability
  • 148. HornetQ REST API • RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html • Simple REST/HTTP interface to access HornetQ • Usable by any programming language that has an HTTP client library • Zero client footprint (no libraries to download, install and deploy) • No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message • Ligthweight interoperability • Pub/Sub (topics) and Point-to-point (queues)
  • 150. HornetQ REST API • Follow the headers
  • 151. HornetQ REST API • Follow the headers • Duplicate Detection
  • 152. HornetQ REST API • Follow the headers • Duplicate Detection • Persistent messages ?durable=true
  • 153. Send a Message [1/2] => Query the resource URL HEAD /topics/jms.topic.trackers HTTP/1.1 Host: example.com --- Response --- HTTP/1.1 200 Ok msg-create: http://example.com/topics/jms.topic.trackers/create msg-create-with-id: http://example.com/topics/jms.topic.trackers/ create/{id}
  • 154. Send a Message [2/2] POST /topics/jms.topic.trackers/create Host: example.com Content-Type: application/json { "alias": "jmesnil", "position": { "coords": { "longitude": 65.735344446666666, "latitude": 35.198200083333326 }, "timestamp": 1285943662645 } } --- Response --- HTTP/1.1 201 Created msg-create-next: http://example.com/topics/jms.topic.trackers/create/ 002
  • 155. Receive a Message - Pull [1/4] => query the resource URL HEAD /topics/jms.topic.trackers HTTP/1.1 Host: example.com --- Response --- HTTP/1.1 200 Ok msg-create: http://example.com/topics/jms.topic.trackers/create msg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/ pull-subscriptions msg-push-subscriptions: http://example.com/topics/jms.topic.trackers/ push-subscriptions
  • 156. Receive a Message - Pull [2/4] => create a subscription by doing an empty POST on the msg-pull-subscriptions URL POST /topics/jms.topic.trackers/pull-subscriptions HTTP/1.1 Host: example.com --- Response --- HTTP/1.1 201 Created Location: http://example.com/topics/jms.topic.trackers/pull- subscriptions/auto-ack/222 msg-consume-next: http://example.com/topics/jms.topic.trackers/pull- subscriptions/auto-ack/222/consume-next-1
  • 157. Receive a Message - Pull [3/4] => consume the message by POSTing on the subscription POST /topics/jms.topic.trackers/pull-subscriptions/auto-ack/222/consume-next-1 Host: example.com --- Response --- HTTP/1.1 200 Ok Content-Type: application/json msg-consume-next: http://example.com/topics/jms.topic.trackers/pull- subscriptions/auto-ack/222/consume-next-2 { "alias": "jmesnil", "position": { "coords": { "longitude": 65.735344446666666, "latitude": 35.198200083333326, ... }, "timestamp": 1285943662645 } }
  • 158. Receive a Message - Pull [4/4] => if there is no message to consume, will return 503 POST /queues/jms.queue.bar/pull-consumers/consume-next-2 Host: example.com --- Response --- Http/1.1 503 Service Unavailable Retry-After: 5 msg-consume-next: http://example.com/queues/jms.queue.bar/pull- consumers/333/consume-next-2
  • 159. Receive a Message - Push[1/2] => query the Topic resource URL HEAD /topics/jms.topic.trackers HTTP/1.1 Host: example.com --- Response --- HTTP/1.1 200 Ok msg-create: http://example.com/topics/jms.topic.trackers/create msg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/ pull-subscriptions msg-push-subscriptions: http://example.com/topics/jms.topic.trackers/ push-subscriptions
  • 160. Receive a Message - Push[2/2] => create a push subscription POST /topics/jms.topic.trackers/push-subscriptions Host: example.com Content-Type: application/xml <push-topic-registration> <link rel="template" href="http://somewhere.com/resources/{id}/ messages" method="POST"/> </push-topic registration> --- Response --- HTTP/1.1 201 Created Location: http://example.com/topics/jms.topic.trackers/push- subscriptions/1-333-1212 => new messages will be POSTed to http://somewhere.com/resources/ {id}/messages URL
  • 161. Create a Destination POST /topics Host: example.com Content-Type: application/hornetq.jms.topic+xml <topic name="testTopic" /> --- Response --- HTTP/1.1 201 Created Location: http://example.com/topics/jms.topic.testTopic
  • 162. HTML5
  • 165. HTML5 • http://www.w3.org/TR/html5/ • Revision of HTML markup language • JavaScript APIs
  • 166. HTML5 • http://www.w3.org/TR/html5/ • Revision of HTML markup language • JavaScript APIs • canvas, geolocation, video, audio, etc.
  • 167. HTML5 • http://www.w3.org/TR/html5/ • Revision of HTML markup language • JavaScript APIs • canvas, geolocation, video, audio, etc. • WebSocket!
  • 169. HTML5 WebSocket • «TCP for the Web»...
  • 170. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server
  • 171. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server • same-origin security model
  • 172. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server • same-origin security model • JavaScript API in the browser
  • 173. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server • same-origin security model • JavaScript API in the browser • http://dev.w3.org/html5/websockets/
  • 174. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server • same-origin security model • JavaScript API in the browser • http://dev.w3.org/html5/websockets/ • WebSocket protocol on the server
  • 175. HTML5 WebSocket • «TCP for the Web»... • bidirectional communication between the browser and the web server • same-origin security model • JavaScript API in the browser • http://dev.w3.org/html5/websockets/ • WebSocket protocol on the server • http://tools.ietf.org/html/draft-hixie- thewebsocketprotocol-76
  • 177. STOMP Over WebSocket • WebSocket instead of TCP
  • 178. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol
  • 179. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol • JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple
  • 180. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol • JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple • ActiveMQ, RabbitMQ(?)
  • 181. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol • JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple • ActiveMQ, RabbitMQ(?) • Talks about adding it to STOMP 2.0 specification
  • 182. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol • JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple • ActiveMQ, RabbitMQ(?) • Talks about adding it to STOMP 2.0 specification • Work with text only (no bytes)
  • 183. STOMP Over WebSocket • WebSocket instead of TCP • STOMP as the messaging protocol • JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple • ActiveMQ, RabbitMQ(?) • Talks about adding it to STOMP 2.0 specification • Work with text only (no bytes) • Receive message by push-only
  • 185. Demo
  • 187. STOMP Over WebSocket • JavaScript-based
  • 188. STOMP Over WebSocket • JavaScript-based • Looks like other STOMP clients
  • 189. STOMP Over WebSocket • JavaScript-based • Looks like other STOMP clients • Send and receive text-only messages
  • 190. Create a Client // create a client var url = "ws://example.com:61614/stomp"; var client = Stomp.client(url); // connect to the STOMP server client.connect(login, passcode, function() { // called back after the client is connected // and authenticated to the server }); ... // disconnect from the server client.disconnect();
  • 191. Send and Receive Messages // send a message var tracker = ...; // retrieved from Geolocation API client.send("jms.topic.trackers", {}, JSON.stringify(tracker)); // subscribe to a destination var sub_id = client.subscribe("jms.topic.trackers", function(message) { // called back everytime a message is sent to the destination var tracker = JSON.parse(message.body); ... }); // unsubscribe from a destination client.unsubscribe(sub_id);
  • 193. REST or WebSocket? • Different usage and timeline
  • 194. REST or WebSocket? • Different usage and timeline • WebSocket
  • 195. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like
  • 196. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like • (+) push data from the server to the browser
  • 197. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand
  • 198. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand • REST
  • 199. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand • REST • (+) Works everywhere now
  • 200. REST or WebSocket? • Different usage and timeline • WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand • REST • (+) Works everywhere now • (-) No push messages in the browser
  • 202. Conclusion • Different ways to do messaging on the Web
  • 203. Conclusion • Different ways to do messaging on the Web • Integrate with the whole Java / Java EE ecosystem
  • 204. Conclusion • Different ways to do messaging on the Web • Integrate with the whole Java / Java EE ecosystem • Embraces Web principles (REST)
  • 205. Conclusion • Different ways to do messaging on the Web • Integrate with the whole Java / Java EE ecosystem • Embraces Web principles (REST) • Integration & interoperability
  • 206. Conclusion • Different ways to do messaging on the Web • Integrate with the whole Java / Java EE ecosystem • Embraces Web principles (REST) • Integration & interoperability • ... Performance(?)

Notas do Editor

  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
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n
  185. \n
  186. \n
  187. \n
  188. \n
  189. \n