Enterprise Messaging with Apache ActiveMQ

46
Enterprise Messaging with Apache ActiveMQ James Strachan http://macstrac.blogspot.com / http://open.iona.com /

description

 

Transcript of Enterprise Messaging with Apache ActiveMQ

Page 1: Enterprise Messaging with Apache ActiveMQ

Enterprise Messaging withApache ActiveMQ

James Strachanhttp://macstrac.blogspot.com/

http://open.iona.com/

Page 2: Enterprise Messaging with Apache ActiveMQ

What is messaging?

Page 3: Enterprise Messaging with Apache ActiveMQ

Messaging 101

Page 4: Enterprise Messaging with Apache ActiveMQ

Topics

Page 5: Enterprise Messaging with Apache ActiveMQ

Queues

Page 6: Enterprise Messaging with Apache ActiveMQ

What is Apache ActiveMQ?

Page 7: Enterprise Messaging with Apache ActiveMQ

What is Apache ActiveMQ

http://activemq.apache.org/

Page 8: Enterprise Messaging with Apache ActiveMQ

Clients

C Java Pike

C++ JavaScript Python

C#/.NET Perl Ruby

Flash PHP Smalltalk

Page 9: Enterprise Messaging with Apache ActiveMQ

Selectors

• Provide content based filtering on messages using SQL 92 syntax

• Customer = ‘gold’ and product in (1, 2, 3) and JMSPriority > 5

• Supports XPath on the message body for XML messages

Page 10: Enterprise Messaging with Apache ActiveMQ

Wildcards

•Products.Books.Computing.EIP

•Products.Books.Computing.*

•Products.>

Page 11: Enterprise Messaging with Apache ActiveMQ

Broker Architecture

Page 12: Enterprise Messaging with Apache ActiveMQ

Message Persistence

Page 13: Enterprise Messaging with Apache ActiveMQ

Security

Page 14: Enterprise Messaging with Apache ActiveMQ

Transports

Page 15: Enterprise Messaging with Apache ActiveMQ

URIs

<protocol>://<host>:<port>?<transport-options>

Examples

tcp://localhost:61616

vm://localhost?broker.persistent=false

Page 16: Enterprise Messaging with Apache ActiveMQ

Failover

failover:(tcp://host1:61616,tcp://host2:61616)?initialReconnectDelay=100

Page 17: Enterprise Messaging with Apache ActiveMQ

Wire Formats

•OpenWire

•STOMP

•HTTP / REST

Page 18: Enterprise Messaging with Apache ActiveMQ

Wire Formats: OpenWire

•binary

•small and fast

•code generated marshalling in C, C++, C# and Java

•a fair amount of work to port to other languages

Page 19: Enterprise Messaging with Apache ActiveMQ

Wire Formats: STOMP

•text based for the headers like HTTP

•very easy to create a client in any language

•tons of clients in most popular programming languages

Page 20: Enterprise Messaging with Apache ActiveMQ

Stomp : Connecting

CONNECT

login:<username>

passcode:<passcode>

^@

Page 21: Enterprise Messaging with Apache ActiveMQ

Stomp : Sending

SENDdestination:/queue/orders.booksreply-to:/temporaryQueue/Jamescorrelation-id:4324234amazonSecurityToken:abc234amazonCustomerRating:gold

<order id=“123” customer=“jstrachan”> <book isin=“1234”/> <book isin=“456”/></order>^@

Page 22: Enterprise Messaging with Apache ActiveMQ

Stomp: Subscribe

SUBSCRIBEdestination:/queue/orders.books

^@

Page 23: Enterprise Messaging with Apache ActiveMQ

Stomp : Receive messages

MESSAGEdestination:/queue/orders.booksMessage-id:abc123reply-to:/temporaryQueue/james134

This is the message^@

Page 24: Enterprise Messaging with Apache ActiveMQ

Broker Architecture

Page 25: Enterprise Messaging with Apache ActiveMQ

Types of connectors

Page 26: Enterprise Messaging with Apache ActiveMQ

Kinds of topology

Page 27: Enterprise Messaging with Apache ActiveMQ

Kinds of topology

Page 28: Enterprise Messaging with Apache ActiveMQ

Kinds of topology

Page 29: Enterprise Messaging with Apache ActiveMQ

Clustering with Master / Slave

•Pure

•Shared File System

•Shared Database

Page 30: Enterprise Messaging with Apache ActiveMQ

Cool Stuff!

Page 31: Enterprise Messaging with Apache ActiveMQ

Monitoring

Page 32: Enterprise Messaging with Apache ActiveMQ

Easy Unit Testing of JMS code

ConnectionFactory factory =

new ActiveMQConnectionFactory(“vm://localhost?broker.persistent=false”);

Page 33: Enterprise Messaging with Apache ActiveMQ

Visualisation

Page 34: Enterprise Messaging with Apache ActiveMQ

Prefetch

new ActiveMQQueue("TEST.QUEUE?consumer.prefetchSize=10");

Page 35: Enterprise Messaging with Apache ActiveMQ

Exclusive Consumers

Page 36: Enterprise Messaging with Apache ActiveMQ

Message Groups

Page 37: Enterprise Messaging with Apache ActiveMQ

Total Ordering

Page 38: Enterprise Messaging with Apache ActiveMQ

Consumer Priority

new ActiveMQQueue("TEST.QUEUE?consumer.priority=10");

Page 39: Enterprise Messaging with Apache ActiveMQ

Virtual Destinations

Page 40: Enterprise Messaging with Apache ActiveMQ

Mirrored Queues

Page 41: Enterprise Messaging with Apache ActiveMQ

Enterprise Integration Patterns via Camel

http://activemq.apache.org/camel/

Page 42: Enterprise Messaging with Apache ActiveMQ

Bridge to other protocols

http://activemq.apache.org/camel/components.html

activemq ibatis mail rmi udp

activemq.journal imap mina rnc validation

bean irc mock rng velocity

cxf jdbc msv seda vm

direct jetty multicast sftp xmpp

event jbi pojo smtp xquery

file jms pop string-template xslt

ftp jpa quartz timer webdav

http log queue tcp

Page 43: Enterprise Messaging with Apache ActiveMQ

Example

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="file://quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="activemq:WidgetQuotes"/> </filter> </route> </camelContext>

Page 44: Enterprise Messaging with Apache ActiveMQ

Where do I get more info?

http://activemq.apache.org/

Page 45: Enterprise Messaging with Apache ActiveMQ

Questions?

Page 46: Enterprise Messaging with Apache ActiveMQ

James Strachan

blog

http://macstrac.blogspot.com/