Ranker jms implementation

26
Ranker JMS Implementation

description

 

Transcript of Ranker jms implementation

Page 1: Ranker jms implementation

Ranker JMS Implementation

Page 2: Ranker jms implementation

Agenda

● Why Event Processing System For Ranker?

● What are challenges?

● General Overview of JMS

● Walk through ActiveMQ

● Why Messaging?

● Other JMS Providers.

Page 3: Ranker jms implementation

Why Messaging?

● Asynchronous operation− A client can schedule work to be done and return immediately− A client can be notified in an event-driven fashion when something has happened

● Loose Coupling− Systems connected via messaging need not be aware of each other, or use the same technologies− Key messages can easily be routed to many systems− Message broker is buffer in case of downtime

Page 4: Ranker jms implementation

Why Messaging?

● Fire and Forget − Message Broker can guarantee messages are recorded and delivered even vs. crashes

● Parallelize Work − Messages in a single stream can be handled in parallel by many client threads or systems

● Throttle Work − A large amount of work can be split into a small number of threads or systems to throttle effort (e.g. due to licensing restrictions)

Page 5: Ranker jms implementation

Why Event Processing System For Ranker?● Ranker has a lot of complicated algorithms running behind

and user really does not need to wait till the execution of all the algorithms.

● You may wish to implement this because the request take a long time to complete or because several parties may be interested in the actual request

● Eg: Crowd ranked/Vote ranked List aggregation (This algorithm may take 1- 5 mts to complete depends of user contribution.)

● Email sending functionality.

● Moderation of user input (eg. Bad word filtering)

● List Auto tagging.

Page 6: Ranker jms implementation

What are the challenges?

● Selecting the JMS provider − We are running the app based on Spring 3.0/Apache tomcat stack, we have to select the appropriate JMS provider. We selected Apache ActiveMQ.

● Reasons for selecting ActiveMQ− Its pretty easy to integrate with Spring Framework.− Open source project.− Pretty good documentation available for ActiveMQ as well as for Integration with spring framework.

Page 7: Ranker jms implementation

What is JMS?

● A specification that describes a common way for Java programs to create, send, receive and read distributed enterprise messages

● Loosely coupled communication● Asynchronous messaging● Reliable delivery

- A message is guaranteed to be delivered once and only once.

● Outside the specification- Security services- Management services

Page 8: Ranker jms implementation

A JMS Application

● JMS Clients- Java programs that send/receive messages

● Messages- Administered Objectspreconfigured JMS objects created by an admin for the use of clients- ConnectionFactory, Destination (queue or topic)

● JMS Provider- messaging system that implements JMS and administrative functionality

Page 9: Ranker jms implementation

JMS Administration

Page 10: Ranker jms implementation

JMS Messaging Domains

● Point-to-Point (PTP)

○ Built around the concept of message queues○ Each message has only one consumer

● Publish-Subscribe systems

○ Uses a “topic” to send and receive messages○ Each message has multiple consumers

Page 11: Ranker jms implementation

Point-to-Point Messaging

Page 12: Ranker jms implementation
Page 13: Ranker jms implementation

Message Consumptions

● Synchronously

○ A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method.

○ The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.

● Asynchronously

○ A client can register a message listener with a consumer.

○ Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener's onMessage() method.

Page 14: Ranker jms implementation

Page 1

Page 15: Ranker jms implementation

JMS Message Types

Page 16: Ranker jms implementation

More JMS Features

● Durable subscription

● By default a subscriber gets only messages published on a topic while a subscriber is alive

● Durable subscription retains messages until a they are received by a subscriber or expire

Page 17: Ranker jms implementation

More JMS Features

Difference Between Persistent & Nonpersistent deliveries

− Persistent delivery take cares of reprocessing the request if the JMS broker restarted before serving the request, it will use file/db to store the request, this implementation is costly compare to non persistent delivery.

− Nonpersistent delivery will just ignore the request if broker restarted while serving the request.

Page 18: Ranker jms implementation

About ActiveMQ

● An open-source message broker (compare to JBossMQ, or many commercial products)

− See http://activemq.apache.org/● Generally stable and high-performance● Can be run standalone, or inside another process, app

server, or Java EE application● Supports everything JMS requires, plus various

extensions● Integrates well into other products

Page 19: Ranker jms implementation

ActiveMQ Message Extensions

● Virtual Destinations (load-balancing and failover for topics)

● Retroactive Subscriptions (subscriber can receive some number of previous messages on connect)

● Exclusive Consumers & Message Groups (loadbalancing and failover while preserving message ordering)

● Mirrored queues (monitor queue messages)

Page 20: Ranker jms implementation

ActiveMQ Client Connectivity

● Dictated by the wire protocol a client uses to talk to the broker

● Generally there are two protocol options – OpenWire (binary) and Stomp (text)− OpenWire is the default and has the most history and best support (including SSL) – for Java, .NET, etc.− Stomp is easiest to develop for and therefore has the most cross-language support (Perl, Python, Ruby, ...)

● Also a variety of other special-purpose protocols (Jabber, adapters for REST/AJAX, etc.)

Page 21: Ranker jms implementation

ActiveMQ Persistence Options

● Different strategies available for storing persistent messages− to local files, database, etc.− or both – stored to local files and then periodically batch undelivered messages to the DB...

● Default implementation changed between ActiveMQ 4.x and 5.x

● May still customize the persistence engine based on specific performance requirements

Page 22: Ranker jms implementation

ActiveMQ SecurityAnd Management

● OpenWire protocol can use SSL for encryption

● Broker can use authentication (e.g. username/password required to connect)− Uses JAAS to identify the back-end user data store (properties files, DB, LDAP, etc.)

● JMX management enabled by default− Use a tool like JConsole to monitor queues, etc.

● Web Console available as well

Page 23: Ranker jms implementation

ActiveMQ Testing

● ActiveMQ can easily run in an embedded, nonpersistent, in-VM only mode for unit tests

● Also easily to run ActiveMQ via beans in a Spring context, if you're testing with Spring

● ActiveMQ includes a simple JNDI provider if you want to test Java EE code that relies on JNDI lookups to access JMS resources

● Can use tools like JMeter to load test the broker

Page 24: Ranker jms implementation

JMS Providers

● SunONE Message Queue (SUN)○ A JMS provider integrated with the SunONE

Application Server○ http://www.sun.com

● MQ JMS (IBM)○ MQSeries is another messaging technology○ Can configure MQ as a JMS provider○ (http://www7b.software.ibm.

com/wsdd/library/techtip/0112_cox.html)

Page 25: Ranker jms implementation

JMS Providers

● WebLogic JMS (BEA)○ Enterprise-class messaging system integrated into

WebLogic Server○ http://dev2dev.bea.com/technologies/jms/index.jsp

● JMSCourier (Codemesh)○ Merging C++ applications into a JMS environment○ http://www.codemesh.

com/en/AlignTechnologyCaseStudy.html

Page 26: Ranker jms implementation

More JMS Vendors

● Fiorano Software http://www.fiorano.com● JRUN Server http://www.allaire.com● GemStone http://www.gemstone.com● Nirvana http://www.pcbsys.com● Oracle http://www.oracle.com● A more exhaustive listing is available at● http://java.sun.com/products/jms/vendors.html