Connecting applicationswitha mq

Embed Size (px)

DESCRIPTION

Overview of JBoss A-MQ

Citation preview

  • 1. Connecting Applications withRed Hat JBoss A-MQRob DaviesTechnical Director, FuseSeptember 2014

2. Rob Davies Red Hat Director, Engineering xPaaS Technical Director of Fuse Engineering Over 20 years experience of developinglarge scale solutions for telcos and finance Creator of ActiveMQ and ServiceMix Committer on open source projects,including Apache Camel 2 RED HAT | Fuse Rocks!2 3. Why use Message-Oriented Middleware ? Robustness to change Time Independence Location Independence Hide Latency Scalability Event driven Simplicity Configurable Quality of Service Platform and Language Integration Fault tolerantProcessA Queue:FooProcessBProcess3 RED HAT | Fuse Rocks!3BrokerMessageinMessage out after enrichmentby Process BCQueue:Bar 4. Top Level Apache Software Foundation Project Wildly popular, high performance, reliable message broker Connects to nearly everythingNative Java, C/C++, .Net,AMQP 1.0, MQTT 3.1, STOMP (1.0-1.2) and OpenWireSTOMP enables Ruby, JS, Perl, Python, PHP, ActionScript Embedded and standalone deployment options The key component of JBoss A-MQ!4 RED HAT | Fuse Rocks!4What is Apache ActiveMQ ? 5. Messaging:The Basics5 RED HAT | Fuse Rocks! 6. Message Channels and Routing Message ChannelsNamed communication between interested partiesJMS calls them Destinations Can tune-in to multiple channels using wildcards Can fine-tune message consumption with selectors Can route a message based on content6 RED HAT | Fuse Rocks!6 7. Message Channels = JMS Destinations7 RED HAT | Fuse Rocks!7Broker ConsumerConsumerDestinationWIDGETDestinationORDERProducerConsumer 8. Point-to-Point channel = JMS Queue8 RED HAT | Fuse Rocks!8ConsumerProducer Queue ConsumerConsumer 9. Publish/Subscribe channel = JMS Topic9 RED HAT | Fuse Rocks!9ProducerConsumerConsumerConsumerTopic 10. Message Routing: Selectors10 RED HAT | Fuse Rocks!10Producer DestinationConsumeColorr =blueConsumeColorr =red 11. Message Routing: Destination Wildcards * matches a subject > matches sub-tree11 RED HAT | Fuse Rocks!11Topic:BAR.BEER.WHITETopic:BAR.WINE.WHITEProducerConsumerTopic:BAR.>ConsumerTopic:BAR.*.WHITEConsumerTopic:BAR.WINE.WHITEConsumerTopic:BAR.BEER.WHITE 12. Message Delivery Mode Messages can be persisted allowing for decoupledapplications For Queues, any message delivered as PERSISTENT must bestored on long term storage before being delivered to aconsumer For Topics, a message delivered as PERSISTENT will only bestored if there exists a durable subscriber NON-PERSISTENT messages may also be stored on disk if thememory limits of the broker have been reached12 RED HAT | Fuse Rocks!12 13. Messaging:Features every message brokershould have 13 RED HAT | Fuse Rocks! 14. Exclusive Consumers14 RED HAT | Fuse Rocks!14ConsumerConsumerConsumerProducer Queue 15. Message Groups Like Exclusive Consumers but in parallel Guaranteed ordering of related messages across a Queue But load balancing of messages across multiple consumers All messages with the same JMSXGroupID go to the same consumer How you group messages is down to the applications producer To explicitly close a group, set the JMSXGroupSeq to -115 RED HAT | Fuse Rocks!15 16. Message Groups Code example16 RED HAT | Fuse Rocks!16//Starting a Group Message message = session.createTextMessage("hiDevNation");message.setStringProperty("JMSXGroupID", RHT_NYSE");producer.send(message);//Close a Group Message message = session.createTextMessage("byeDevNation");message.setStringProperty("JMSXGroupID", RHT_NYSE");message.setStringProperty("JMSXGroupSeq", -1);producer.send(message); 17. Message Groups17 RED HAT | Fuse Rocks!17ProducerConsumerConsumerConsumerQueue:Prices 18. Deployment ActiveMQ Can run standalone or embedded As a standalone, or part of a highly available messagebroker cluster Embedded easy to use an entire broker in JUnit tests(no need to Mock) In Tomcat, deployed as a war In JEE Server either co-locate or use client with JCAActiveMQ distributions contain a rar for this purpose18 RED HAT | Fuse Rocks!18 19. JBoss A-MQ19 RED HAT | Fuse Rocks!19 20. Messaging:Persistence20 RED HAT | Fuse Rocks! 21. Different Storage Options SQL (JDBC) KahaDB LevelDB21 RED HAT | Fuse Rocks!21Slow but popularThe currentdefaultThe best yet 22. ActiveMQ Message Storage22 22 RED HAT | Fuse Rocks! 23. LevelDB vs KahaDB Fewer index entries per message than KahaDB Faster recovery when a broker restarts LevelDB index out-perform Btree index at sequentialaccess LevelDB indexes support concurrent read access Pause-less data log file garbage collection cycles Fewer IOPS to load stored messages It exposes it's status via JMX for monitoring23 RED HAT | Fuse Rocks!23 24. LevelDB vs KahaDB (cont.)24 RED HAT | Fuse Rocks!24 25. Messaging:Protocols25 RED HAT | Fuse Rocks! 26. OpenWireAdvantages: Disadvantages:26 RED HAT | Fuse Rocks!26 Fast optimized forActiveMQ client failover automatic reconnect Client load balancing Flow control Many advanced features Not a recognizedstandard Only Java, C/C++/.Net 27. MQTTAdvantages: Disadvantages:27 RED HAT | Fuse Rocks!27 light weight telemetrytransport Standard out of OASIS Adoption by a large cross-section,from Facebook(Messenger) toembedded devices Version 3.x onlysupportspublish/subscribe No advance features,such as flow control 28. AMQPAdvantages: Disadvantages:28 RED HAT | Fuse Rocks!28 AMQP 1.0 OSASISstandard Feature rich messagingprotocol C/C++/Java clients andmore in development Currently, only client tobroker supported inActiveMQ 29. STOMPAdvantages: Disadvantages:29 RED HAT | Fuse Rocks!29 Easy to implement Defacto standard: ActiveMQ + Apollo HornetQ RabbitMQ PocoMQ StompServer OpenMQ Many more Not as fast a binaryformats 30. Websockets STOMP is a natural wire protocol for WebSockets And so is MQTT!HTTP(S)Request/Response30 RED HAT | Fuse Rocks!30ActiveMQClient(Browser)WebSocketConnectorStompConverterActiveMQ(Backend)TCP(WebSocket) 31. Configuring protocols31 RED HAT | Fuse Rocks!31 32. High Availability32 RED HAT | Fuse Rocks! 33. Master/Slave Shared Message Store Replicated LevelDB Master/Slave33 RED HAT | Fuse Rocks!33 34. Messaging:High Availability34 RED HAT | Fuse Rocks! 35. FailoverSupported by both Java and C++ OpenWireclientsActiveMQClusterActiveMQClient35 RED HAT | Fuse Rocks! 36. High Availability with shared storageActiveMQClusterActiveMQClient36 RED HAT | Fuse Rocks! 37. Replicated LevelDB37 RED HAT | Fuse Rocks!Registry(ZooKeeper)ActiveMQClient 38. Messaging:Store and Forward (Networks)38 RED HAT | Fuse Rocks! 39. Networks of BrokersLink Brokers togetherUse Store and ForwardAre uni-directional by defaultAll Destinations are global39 RED HAT | Fuse Rocks!39 40. Networks of Brokers40 RED HAT | Fuse Rocks!40 41. Store and Forward41 RED HAT | Fuse Rocks!41 42. Bi-directional network42 RED HAT | Fuse Rocks!42 43. Bi-directional Configuration43 RED HAT | Fuse Rocks!43 44. Reducing cross-talk"/>"/>"/>44 RED HAT | Fuse Rocks!44"/>"/>"/> 45. Scaling Networks45 RED HAT | Fuse Rocks!45 Brokers share routing information across networks All destinations are considered Global easy to use Though it starts to get problematic with 1000s ofbrokers However we can do filtering to shape the trafficacross networks But this involves a lot of manual configurationTime to talk about Apache Camel 46. ActiveMQ and Apache Camel46 RED HAT | Fuse Rocks!46S e rviceC o nsum e rC o nsum e rA ctiveM Q B ro ke r 47. ActiveMQ Broker47 RED HAT | Fuse Rocks!47TopicsQueuesMessage StoreJMX JaaS Advisoryscheduler 48. ActiveMQ Broker48 RED HAT | Fuse Rocks!48TopicsQueuesMessage StoreJMX JaaS AdvisoryschedulerBroker 49. ActiveMQ with embedded Camel49 49 RED HAT | Fuse Rocks! 50. Setup Camel Context in the usual way$foo = 'bar'$foo = 'cheese'50 50 RED HAT | Fuse Rocks! 51. Scaling Networks with Camel51 RED HAT | Fuse Rocks!51 Allows for non-chatty networks to be established Routing information can be externalized to the broker Successfully used in production for 1000s of brokerstoday 52. Messaging:More Problems with largedeployments52 RED HAT | Fuse Rocks! 53. Deployment and Maintenance53 RED HAT | Fuse Rocks!53Main problemsInstalling brokers on multiple hostsssh, untar, set directories and environmentSetting configuration manually for every brokercopying xml config, tweaking, testingUpdating configuration across clusterUpgrading brokers 54. Best practices for ActiveMQ only54 RED HAT | Fuse Rocks!54 Keep XML as a template and configure node-specificdetails through properties Keep configuration in SVC system (git, svn, ) Keep configuration separate from installation foreasier upgrades 55. Clients55 RED HAT | Fuse Rocks!55 Topology is very static Clients need to be aware of topology Clients need to know broker locations Changes are not easy as clients need to be updated Adding new resources (brokers) requires client updates Not suitable for cloud deployments 56. Fabric8 to the rescue!56 RED HAT | Fuse Rocks! 57. Messaging:Use cases57 RED HAT | Fuse Rocks! 58. Not space - but close58 RED HAT | Fuse Rocks!58 59. Running the biggest machine on the planet59 RED HAT | Fuse Rocks!59 60. Messaging:The Internet of Things60 RED HAT | Fuse Rocks! 61. The Internet of Things (IoT)61 RED HAT | Fuse Rocks!61 Uniquely identifiable objects and their virtualrepresentations in an internet-like structure Originally defined by Kevin Ashton, co-founder of Auto-IDcenter at MIT Today its meaning has evolved to encompass a worldwhere physical objects are integrated into the informationnetwork, and where physical objects participate in businessprocesses. 62. Telemetry62 RED HAT | Fuse Rocks!62 M2M involves collection and transmission of event leveldata (used to be called telemetry) from intelligent devices Machines can interact over the net and/or attachednetworks by wired and wireless networks Payloads are typically minimal (temperature, pressure,location, metering etc.) 63. IoT predicted Growth50 Billion10 BillionRFID tags forInventory control1 BillionUbiquitouspositioning locating people andeveryday objectsGeo-located devicesMicrocontrollersinternet enabled63 RED HAT | Fuse Rocks!63Vending machines, loneworkers, POS, vehicles,planes, tolls, powersystems, transport,telemedicine, homeappliances, powersystems, etc.TimeConnected Devices on theinternetAdvanced sensors,Enterprises fullyconnected: integrationof everything2000 2010 2020 64. Collect IOT informationMessaging Platform(Multi-protocol,Multi-platform)JBoss A-MQMobilewirelessMedical DevicesIndustrialMachinesDistribution/Delivery VehiclesEnergy MonitoringEquipmentSensorsMQTTAMQP64 RED HAT | Fuse Rocks!Aggregate IOT datareliablyReal-time notificationLightweight, embeddablemessaging 65. Integrate IOT informationMessaging Platform(Multi-protocol,Multi-platform)JBoss A-MQIOT dataEnterprise ServiceBus(Mediate,Transform, Route,Connect)JBoss Fuse65 RED HAT | Fuse Rocks!SaaS/CloudapplicationsEnterpriseapplicationsCRMapplicationUnlockinformation,services,processesLightweight, embeddable,enterprise integrationpattern based platform 66. IOT Red Hat JBoss solution66 RED HAT | Fuse Rocks! 67. Messaging:IoT Demo67 RED HAT | Fuse Rocks! 68. What is Arduino ?68 RED HAT | Fuse Rocks!68 Open Source Hardware microcontroller Cheap and easily available. Open Source Software. Widespread: many projects. Extra HW (shields) available 69. USB7-12 v3 v GRD5 vGRD69 69 RED HAT | Fuse Rocks!Transmitter/ReceiverSerial ConnectionMicrocontrollerATmega328Operating Voltage 5VInput Voltage(recommended)7-12VInput Voltage (limits)6-20VDigital I/O Pins 14(of which 6 provide PWMoutput)Analog Input Pins 6DC Current per I/O Pin40 mADC Current for 3.3V Pin50 mADigital Input/Output PinsPins with ~ are PWM[Analog Output]Analog Input Pins 70. Arduino Programming70 RED HAT | Fuse Rocks!70 3 types of memory on ArduinoFlash memory (program space) 32 KbSRAM used by sketches 2 KbEPROM long term memory 1 Kb Programming language based on Wiring: C/C++ librarydesigned to make input/output easier. Programs are calledsketches. Arduino has a simple IDE, available on Windows, Linux andMac 71. Arduino MQTT to WebSockets71 RED HAT | Fuse Rocks!71ArduinoAMQPMQTTActiveMQMQTT/AMQPGatewayActiveMQAMQP/WebSocketsBroker HTML 5/WebSockets 72. QQuueessttiioonnssaannddDDiissccuussssiioonn72 RED HAT | Fuse Rocks!