SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
Messaging With
Apache ActiveMQ
  Bruce Snyder
  bsnyder@apache.org
  19 Nov 2008
  Malmo, Sweden
Do You Use JMS?




                  2
A Crash Course in Messaging

:: JMS is:
   :: An API for enterprise messaging
   :: Included in Java EE
    :: Also available stand alone
  :: Loosely coupled



:: JMS is not:
   :: A message broker implementation




                                        3
JMS Absracts Message Brokers




                               4
The JMS Message




                  5
Point-to-Point Messaging




                           6
Publish-Subscribe Messaging Domain




                                     7
What is ActiveMQ?

:: Message-oriented middleware
:: Apache project
  :: http://activemq.apache.org/
:: Apache licensed
:: JMS 1.1 compliant


:: Goal:
  :: Standards-based, message-oriented application
    integration across many languages and platforms



                                                      8
Examples Demo



    Easily send and receive
     messages using the
       default examples




                              9
Configuration




(conf/activemq.xml)
                      10
ActiveMQ Uses URIs




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




                                                  11
Example URIs


vm://localhost?broker.persistent=false


tcp://localhost:61616?jms.useAsyncSend=true


stomp://localhost:61613


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




                                              12
Wire Formats

:: OpenWire
  :: The default in ActiveMQ; a binary protocol
  :: Clients for C++, Java and .NET

:: STOMP
  :: Simple Text Oriented Messaging Protocol; a text based protocol
  :: Clients for C, Javascript, Perl, PHP, Python, Ruby and more

:: XMPP
  :: The Jabber XML protocol

:: REST
  :: HTTP POST and GET

:: AMQP
  :: Not yet fully supported
                                                                   13
Two Types of Transports




                          14
Transport Connectors

:: Client-to-broker connections
   :: Similar to JDBC connections to a database

:: Protocols are supported:
  :: TCP
  :: UDP
  :: NIO
  :: SSL
  :: HTTP/S
  :: VM
  :: XMPP


                                                  15
Network of Brokers

:: Broker-to-broker connections
:: Protocols supported:
 :: Static
 :: Failover
 :: Multicast
 :: Zeroconf
 :: Peer
 :: Fanout
 :: Discovery




                                  16
Networks of Brokers

:: Provides large scalability
:: ActiveMQ store-and-forward allows
 messages to traverse brokers
 :: Demand-based forwarding
 :: Some people call this distributed queues

:: Many possible configurations or topologies
 are supported




                                                17
Topology Example




                   18
Topology Example




                   19
Topology Example




                   20
Topology Example




                   21
Topology Example




                   22
Message Persistence




                      23
AMQ Message Store

:: Transactional message storage solution
:: Fast and reliable
:: Composed of two parts:
   :: Data Store - holds messages in a transactional journal
   :: Reference store - stores message locations for fast
      retrieval
:: The default message store in ActiveMQ 5




                                                          24
Non-Journaled JDBC

:: Transactional message storage solution
:: Reliable but not fast
 :: JDBC connection overhead is prohibitively slow




                                                     25
Journaled JDBC

:: Transactional message storage solution
:: Reliable and faster than non-journaled
:: Two-piece store
   :: Journal - A high-performance, transactional journal
   :: Database - A relational database of your choice

:: Default database in ActiveMQ 4.x is Apache
  Derby




                                                            26
Message Cursors

:: Messages are no longer stored in memory
   :: Previous to 5.1, message references were stored in
      memory
:: Messages are paged in from storage when
 space is available in memory




                                                           27
Master/Slave Broker Configurations




                                     28
Three Types of Master/Slave

:: Pure master/slave
:: Shared filesystem master/slave
:: JDBC master/slave




                                    29
Pure Master/Slave

:: Shared nothing, fully replicated topology
   :: Does not depend on shared filesystem or database

:: A Slave broker consumes all message states
   from the Master broker (messages, acks, tx
   states)
:: Slave does not start any networking or
   transport connectors




                                                     30
Pure Master/Slave

:: Master broker will only respond to client when a
 message exchange has been successfully
 passed to the slave broker




                                                 31
Pure Master/Slave

:: If the master fails, the slave optionally has two
 modes of operation:
  :: Start up all it’s network and transport connectors
    :: All clients connected to failed Master resume on Slave
  :: Close down completely
    :: Slave is simply used to duplicate state from Master




                                                                32
Shared Filesystem Master/Slave

:: Utilizes a directory on a shared filesystem
:: No restriction on number of brokers
:: Simple configuration (point to the data dir)
:: One master selected at random




                                                  33
JDBC Master/Slave

:: Recommended when using a shared
   database
:: No restriction on the number of brokers
:: Simple configuration
:: Clustered database negates single point of
   failure
:: One master selected at random




                                                34
Client Connectivity With Master/Slave

:: Again, clients should use failover transport:


failover:(tcp://broker1:61616,tcp://broker2:61616, 
tcp://broker3:61616)?initialReconnectDelay=100




                                                       35
Tips for HA and Fault Tolerance

:: RAIDed disks
:: A Storage Area Network
:: Clustered relational databases
:: Clustered JDBC via C-JDBC
 :: http://c-jdbc.objectweb.org/




                                    36
Security




           37
Broker Security

:: Authentication
  :: I.e., are you allowed to connect to ActiveMQ?
  :: File based implementation
  :: JAAS based implementation



:: Authorization
  :: I.e., do you have permission to use that ActiveMQ
     resource?
  :: Destination level
  :: Message level via custom plugin


                                                         38
Consumer Options
:: Message prefetch
:: Consumer dispatch async
:: Exclusive consumer
:: Consumer priority
:: Message groups
:: Redeliery policies
:: Retroactive consumer
:: Selectors
:: Some slow consumer strategies




                                   39
Message Prefetch

:: Used for slow consumer situations
  :: Consumer is flooded by messages from the broker
:: FIFO buffer on the consumer side




                                                       40
Async Dispatch

:: Asynchronous message delivery to consumers
  :: Default is true
:: Useful for slow consumers
  :: Incurs a bit of overhead




                                                41
Exclusive Consumers

:: Anytime more than one consumer is consuming from
 a queue, message order is lost
:: Allows a single consumer to consume all messages
 on a queue to maintain message ordering




                                                      42
Consumer Priority

:: Just like it sounds
  :: Gives a consumer priority for message delivery
  :: Allows for the weighting of consumers to optimize
    network traversal for message delivery




                                                         43
Message Groups
:: Uses the JMSXGroupID property to define which
 message group a message belongs
  :: Guarantees ordered processing of related messages across a
    single destination
  :: Load balancing of message processing across multiple consumers
  :: HA/failover if consumer goes down




                                                                  44
Retroactive Consumer

:: Message replay at start of a subscription
  :: At the start of every subscription, send any old
     messages that the consumer may have missed
  :: Configurable via policies




                                                        45
Wildcards on Destinations
          ...
          <destinationPolicy>
EXAMPLE
            <policyMap>
              <policyEntries>
                <policyEntry topic="Price.Stock.>"
                    memoryLimit="128mb">
              </policyEntries>
            </policyMap>
          </destinationPolicy>
          ...


             :: Price.>
             :: Price.Stock.>
             :: Price.Stock.NASDAQ.*
             :: Price.Stock.*.IBM

                                                     46
Virtual Destinations




                       47
Total Ordering

:: A guaranteed order of messages for each
 consumer




                                             48
Mirrored Queues




                  49
Message Selectors

:: Used to attach a filter to a subscription
:: Defined using a subset SQL 92 syntax
:: JMS selectors
  :: Filters only message properties
    :: JMSType = ‘stock’ and trader = ‘bob’ and price < ‘105’

:: XPath selectors
  :: Filters message bodies that contain XML
    :: ‘/message/cheese/text() = 'swiss'’




                                                                50
Retroactive Consumer

:: Used to go back in time
   :: In terms of messages

:: At the start of a subscription, send old
   messages the consumer may have missed
:: Configurable via timed or fixed size recovery




                                                   51
Slow Consumer Strategies

:: Various configurable strategies for handling slow
   consumers
:: Slow consumer situations are very common
:: Caused by:
  :: Slow network connections
  :: Unreliable network connections
  :: Busy network situations
  :: Busy JVM situations
  :: Half disconnects with sockets




                                                  52
Use Message Limit Strategies

:: PendingMessageLimitStrategy
 :: Calculates the max number of pending messages to
   be held in memory for a consumer above its prefetch
   size
:: ConstantPendingMessageLimitStrategy
 :: A constant limit for all consumers
:: PrefetchRatePendingMessageLimitStrategy
 :: Calculates the max number of pending messages
   using a multiplier of the consumers prefetch size




                                                         53
Use Prefetch and an Eviction Policy

:: Use the prefetch policy
  :: The prefetch policy has a property named
    maximumPendingMessageLimit that can be used on a
    per connection or per consumer basis
:: Use a message eviction policy
  :: OldestMessageEvictionStrategy
    :: Evict the oldest messages first
  :: OldestMessageWithLowestPriorityEvictionStrategy
    :: Evict the oldest messages with the lowest priority first




                                                             54
Use Destination Policies

:: Configured on the destination policies in the
   ActiveMQ XML configuration file
:: Combined with wildcards, this is very powerful




                                                   55
Additional Tips
:: Consider configuring different message cursors
:: The status of slow consumers can be monitored via JMX
 properties
  :: discarded - The count of how many messages have been
    discarded during the lifetime of the subscription due to it being a
    slow consumer
  :: matched - The current number of messages matched and to be
    dispatched to the subscription as soon as some capacity is
    available in the prefetch buffer. So a non-zero value implies that
    the prefetch buffer is full for this subscription




                                                                          56
Monitoring

:: JMX
:: ActiveMQ web console
:: Additional consumers
 :: Camel routes

:: SpringSource AMS
 :: Based on Hyperic
:: IONA FuseHQ
 :: Based on Hyperic




                          57
Visualization




                58
What is Apache Camel?




                        59
What is EIP?




               60
Fluent Java API
          RouteBuilder MyRoute = new RouteBuilder() {
             public void configure() {
EXAMPLE
               from("activemq:TEST.QUEUE").
                 to("file:///Users/bsnyder/camelinbox/text.txt").
                 to("log:MyLog");
             }
          };




                                                                    61
XML Config
          <camelContext id="camel"
            xmlns="http://activemq.apache.org/camel/schema/spring">
EXAMPLE
            <package>com.mycompany</package>
            <route>
              <from uri="activemq:example.A" />
              <to uri="file:///Users/bsnyder/camelinbox/text.txt" />
              <to uri=”log:MyLog?showProperties=true” />
            </route>
          </camelContext>




                                                                62
EIP Pattern: Content Based Router
EXAMPLE


          RouteBuilder builder = new RouteBuilder() {
              public void configure() {

          from("seda:a").choice().when(header("foo").isEqualTo("bar
          ")).to("seda:b")
                      .when(header("foo").isEqualTo("cheese")).to("
          seda:c").otherwise().to("seda:d");
              }
          };

                                                               63
EIP Pattern: Content Based Router
          <camelContext id="buildSimpleRouteWithChoice"
              xmlns="http://activemq.apache.org/camel/schema/spring">
EXAMPLE
            <route>
              <from uri="seda:a"/>
              <choice>
                <when>
                  <predicate>
                    <header name="foo"/>
                    <isEqualTo value="bar"/>
                  </predicate>
                  <to uri="seda:b"/>
                </when>
                <when>
                  <predicate>
                    <header name="foo"/>
                    <isEqualTo value="cheese"/>
                  </predicate>
                  <to uri="seda:c"/>
                </when>
                <otherwise><to uri="seda:d"/></otherwise>
              </choice>
            </route>
          </camelContext>
                                                                        64
Do You Have Information Overload Yet? ;-)




                                      65
Thank You For Attending!




  Questions?

                           66

Weitere ähnliche Inhalte

Was ist angesagt?

ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
Bruce Snyder
 
10135 a 07
10135 a 0710135 a 07
10135 a 07
Bố Su
 

Was ist angesagt? (20)

Spring JMS and ActiveMQ
Spring JMS and ActiveMQSpring JMS and ActiveMQ
Spring JMS and ActiveMQ
 
Mini-Training: Message Brokers
Mini-Training: Message BrokersMini-Training: Message Brokers
Mini-Training: Message Brokers
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
Apache Kafka - Messaging System Overview
Apache Kafka - Messaging System OverviewApache Kafka - Messaging System Overview
Apache Kafka - Messaging System Overview
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
Kafka as Message Broker
Kafka as Message BrokerKafka as Message Broker
Kafka as Message Broker
 
NServiceBus - introduction to a message based distributed architecture
NServiceBus - introduction to a message based distributed architectureNServiceBus - introduction to a message based distributed architecture
NServiceBus - introduction to a message based distributed architecture
 
Introduction to NServiceBus
Introduction to NServiceBusIntroduction to NServiceBus
Introduction to NServiceBus
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
 
10135 a 07
10135 a 0710135 a 07
10135 a 07
 
Kafka tutorial
Kafka tutorialKafka tutorial
Kafka tutorial
 
RabbitMQ vs Apache Kafka - Part 1
RabbitMQ vs Apache Kafka - Part 1RabbitMQ vs Apache Kafka - Part 1
RabbitMQ vs Apache Kafka - Part 1
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Kafka basics
Kafka basicsKafka basics
Kafka basics
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
 
Apache Kafka
Apache Kafka Apache Kafka
Apache Kafka
 
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
 

Andere mochten auch

Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
dejanb
 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQ
Rob Davies
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
Omi Om
 
LOAD BALANCING ALGORITHMS
LOAD BALANCING ALGORITHMSLOAD BALANCING ALGORITHMS
LOAD BALANCING ALGORITHMS
tanmayshah95
 
Dopplr: It's made of messages - Matt Biddulph
Dopplr: It's made of messages - Matt BiddulphDopplr: It's made of messages - Matt Biddulph
Dopplr: It's made of messages - Matt Biddulph
Carsonified Team
 

Andere mochten auch (20)

Advanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQAdvanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQ
 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
 
Active MQ
Active MQActive MQ
Active MQ
 
Server load balancer ppt
Server load balancer pptServer load balancer ppt
Server load balancer ppt
 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQ
 
ActiveMQ 5.9.x new features
ActiveMQ 5.9.x new featuresActiveMQ 5.9.x new features
ActiveMQ 5.9.x new features
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
 
Server Load Balancer Test Methodology
Server Load Balancer Test MethodologyServer Load Balancer Test Methodology
Server Load Balancer Test Methodology
 
Active mq Installation and Master Slave setup
Active mq Installation and Master Slave setupActive mq Installation and Master Slave setup
Active mq Installation and Master Slave setup
 
Mcollective orchestration tool 소개
Mcollective orchestration tool 소개Mcollective orchestration tool 소개
Mcollective orchestration tool 소개
 
모바일 개발 트랜드
모바일 개발 트랜드모바일 개발 트랜드
모바일 개발 트랜드
 
빌링:미터링 Bss platform구현
빌링:미터링 Bss platform구현빌링:미터링 Bss platform구현
빌링:미터링 Bss platform구현
 
토종 개발자가 바라본 실리콘밸리 개발 트랜드
토종 개발자가 바라본 실리콘밸리 개발 트랜드토종 개발자가 바라본 실리콘밸리 개발 트랜드
토종 개발자가 바라본 실리콘밸리 개발 트랜드
 
Introduction to ActiveMQ Apollo
Introduction to ActiveMQ ApolloIntroduction to ActiveMQ Apollo
Introduction to ActiveMQ Apollo
 
클라우드 서비스운영 플랫폼 가루다 Open cloudengine_패스트캣_cto 송상욱
클라우드 서비스운영 플랫폼 가루다 Open cloudengine_패스트캣_cto 송상욱클라우드 서비스운영 플랫폼 가루다 Open cloudengine_패스트캣_cto 송상욱
클라우드 서비스운영 플랫폼 가루다 Open cloudengine_패스트캣_cto 송상욱
 
클라우드 서비스운영 플랫폼 가루다
클라우드 서비스운영 플랫폼 가루다클라우드 서비스운영 플랫폼 가루다
클라우드 서비스운영 플랫폼 가루다
 
LOAD BALANCING ALGORITHMS
LOAD BALANCING ALGORITHMSLOAD BALANCING ALGORITHMS
LOAD BALANCING ALGORITHMS
 
Dopplr: It's made of messages - Matt Biddulph
Dopplr: It's made of messages - Matt BiddulphDopplr: It's made of messages - Matt Biddulph
Dopplr: It's made of messages - Matt Biddulph
 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQPolyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQ
 
범용 PaaS 플랫폼 mesos(mesosphere)
범용 PaaS 플랫폼 mesos(mesosphere)범용 PaaS 플랫폼 mesos(mesosphere)
범용 PaaS 플랫폼 mesos(mesosphere)
 

Ähnlich wie Messaging With Apache ActiveMQ

apachekafka-160907180205.pdf
apachekafka-160907180205.pdfapachekafka-160907180205.pdf
apachekafka-160907180205.pdf
TarekHamdi8
 
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
WSO2
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-Camus
Deep Shah
 

Ähnlich wie Messaging With Apache ActiveMQ (20)

Distributed messaging with Apache Kafka
Distributed messaging with Apache KafkaDistributed messaging with Apache Kafka
Distributed messaging with Apache Kafka
 
Apache Kafka Women Who Code Meetup
Apache Kafka Women Who Code MeetupApache Kafka Women Who Code Meetup
Apache Kafka Women Who Code Meetup
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
apachekafka-160907180205.pdf
apachekafka-160907180205.pdfapachekafka-160907180205.pdf
apachekafka-160907180205.pdf
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
Application Layer Protocols for the IoT
Application Layer Protocols for the IoTApplication Layer Protocols for the IoT
Application Layer Protocols for the IoT
 
Connecting applicationswitha mq
Connecting applicationswitha mqConnecting applicationswitha mq
Connecting applicationswitha mq
 
WSO2 Message Broker - Product Overview
WSO2 Message Broker - Product OverviewWSO2 Message Broker - Product Overview
WSO2 Message Broker - Product Overview
 
Non-Kafkaesque Apache Kafka - Yottabyte 2018
Non-Kafkaesque Apache Kafka - Yottabyte 2018Non-Kafkaesque Apache Kafka - Yottabyte 2018
Non-Kafkaesque Apache Kafka - Yottabyte 2018
 
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
WSO2 Product Release webinar - WSO2 Message Broker 2.2.0
 
Apache KAfka
Apache KAfkaApache KAfka
Apache KAfka
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-Camus
 
Cloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical OverviewCloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical Overview
 
Kafka Overview
Kafka OverviewKafka Overview
Kafka Overview
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Session 23 - Kafka and Zookeeper
Session 23 - Kafka and ZookeeperSession 23 - Kafka and Zookeeper
Session 23 - Kafka and Zookeeper
 
Apache Kafka Reliability
Apache Kafka Reliability Apache Kafka Reliability
Apache Kafka Reliability
 
Kafka RealTime Streaming
Kafka RealTime StreamingKafka RealTime Streaming
Kafka RealTime Streaming
 

Mehr von Bruce Snyder

Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using SpringBeyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Bruce Snyder
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMS
Bruce Snyder
 
Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using Spring
Bruce Snyder
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel Jockey
Bruce Snyder
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
Bruce Snyder
 
Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a Ride
Bruce Snyder
 

Mehr von Bruce Snyder (10)

Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using SpringBeyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMS
 
Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using Spring
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel Jockey
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a Ride
 
EIP In Practice
EIP In PracticeEIP In Practice
EIP In Practice
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Messaging With Apache ActiveMQ

  • 1. Messaging With Apache ActiveMQ Bruce Snyder bsnyder@apache.org 19 Nov 2008 Malmo, Sweden
  • 2. Do You Use JMS? 2
  • 3. A Crash Course in Messaging :: JMS is: :: An API for enterprise messaging :: Included in Java EE :: Also available stand alone :: Loosely coupled :: JMS is not: :: A message broker implementation 3
  • 8. What is ActiveMQ? :: Message-oriented middleware :: Apache project :: http://activemq.apache.org/ :: Apache licensed :: JMS 1.1 compliant :: Goal: :: Standards-based, message-oriented application integration across many languages and platforms 8
  • 9. Examples Demo Easily send and receive messages using the default examples 9
  • 11. ActiveMQ Uses URIs <protocol>://<host>:<port>?<transport-options> 11
  • 13. Wire Formats :: OpenWire :: The default in ActiveMQ; a binary protocol :: Clients for C++, Java and .NET :: STOMP :: Simple Text Oriented Messaging Protocol; a text based protocol :: Clients for C, Javascript, Perl, PHP, Python, Ruby and more :: XMPP :: The Jabber XML protocol :: REST :: HTTP POST and GET :: AMQP :: Not yet fully supported 13
  • 14. Two Types of Transports 14
  • 15. Transport Connectors :: Client-to-broker connections :: Similar to JDBC connections to a database :: Protocols are supported: :: TCP :: UDP :: NIO :: SSL :: HTTP/S :: VM :: XMPP 15
  • 16. Network of Brokers :: Broker-to-broker connections :: Protocols supported: :: Static :: Failover :: Multicast :: Zeroconf :: Peer :: Fanout :: Discovery 16
  • 17. Networks of Brokers :: Provides large scalability :: ActiveMQ store-and-forward allows messages to traverse brokers :: Demand-based forwarding :: Some people call this distributed queues :: Many possible configurations or topologies are supported 17
  • 24. AMQ Message Store :: Transactional message storage solution :: Fast and reliable :: Composed of two parts: :: Data Store - holds messages in a transactional journal :: Reference store - stores message locations for fast retrieval :: The default message store in ActiveMQ 5 24
  • 25. Non-Journaled JDBC :: Transactional message storage solution :: Reliable but not fast :: JDBC connection overhead is prohibitively slow 25
  • 26. Journaled JDBC :: Transactional message storage solution :: Reliable and faster than non-journaled :: Two-piece store :: Journal - A high-performance, transactional journal :: Database - A relational database of your choice :: Default database in ActiveMQ 4.x is Apache Derby 26
  • 27. Message Cursors :: Messages are no longer stored in memory :: Previous to 5.1, message references were stored in memory :: Messages are paged in from storage when space is available in memory 27
  • 29. Three Types of Master/Slave :: Pure master/slave :: Shared filesystem master/slave :: JDBC master/slave 29
  • 30. Pure Master/Slave :: Shared nothing, fully replicated topology :: Does not depend on shared filesystem or database :: A Slave broker consumes all message states from the Master broker (messages, acks, tx states) :: Slave does not start any networking or transport connectors 30
  • 31. Pure Master/Slave :: Master broker will only respond to client when a message exchange has been successfully passed to the slave broker 31
  • 32. Pure Master/Slave :: If the master fails, the slave optionally has two modes of operation: :: Start up all it’s network and transport connectors :: All clients connected to failed Master resume on Slave :: Close down completely :: Slave is simply used to duplicate state from Master 32
  • 33. Shared Filesystem Master/Slave :: Utilizes a directory on a shared filesystem :: No restriction on number of brokers :: Simple configuration (point to the data dir) :: One master selected at random 33
  • 34. JDBC Master/Slave :: Recommended when using a shared database :: No restriction on the number of brokers :: Simple configuration :: Clustered database negates single point of failure :: One master selected at random 34
  • 35. Client Connectivity With Master/Slave :: Again, clients should use failover transport: failover:(tcp://broker1:61616,tcp://broker2:61616, tcp://broker3:61616)?initialReconnectDelay=100 35
  • 36. Tips for HA and Fault Tolerance :: RAIDed disks :: A Storage Area Network :: Clustered relational databases :: Clustered JDBC via C-JDBC :: http://c-jdbc.objectweb.org/ 36
  • 37. Security 37
  • 38. Broker Security :: Authentication :: I.e., are you allowed to connect to ActiveMQ? :: File based implementation :: JAAS based implementation :: Authorization :: I.e., do you have permission to use that ActiveMQ resource? :: Destination level :: Message level via custom plugin 38
  • 39. Consumer Options :: Message prefetch :: Consumer dispatch async :: Exclusive consumer :: Consumer priority :: Message groups :: Redeliery policies :: Retroactive consumer :: Selectors :: Some slow consumer strategies 39
  • 40. Message Prefetch :: Used for slow consumer situations :: Consumer is flooded by messages from the broker :: FIFO buffer on the consumer side 40
  • 41. Async Dispatch :: Asynchronous message delivery to consumers :: Default is true :: Useful for slow consumers :: Incurs a bit of overhead 41
  • 42. Exclusive Consumers :: Anytime more than one consumer is consuming from a queue, message order is lost :: Allows a single consumer to consume all messages on a queue to maintain message ordering 42
  • 43. Consumer Priority :: Just like it sounds :: Gives a consumer priority for message delivery :: Allows for the weighting of consumers to optimize network traversal for message delivery 43
  • 44. Message Groups :: Uses the JMSXGroupID property to define which message group a message belongs :: Guarantees ordered processing of related messages across a single destination :: Load balancing of message processing across multiple consumers :: HA/failover if consumer goes down 44
  • 45. Retroactive Consumer :: Message replay at start of a subscription :: At the start of every subscription, send any old messages that the consumer may have missed :: Configurable via policies 45
  • 46. Wildcards on Destinations ... <destinationPolicy> EXAMPLE <policyMap> <policyEntries> <policyEntry topic="Price.Stock.>" memoryLimit="128mb"> </policyEntries> </policyMap> </destinationPolicy> ... :: Price.> :: Price.Stock.> :: Price.Stock.NASDAQ.* :: Price.Stock.*.IBM 46
  • 48. Total Ordering :: A guaranteed order of messages for each consumer 48
  • 50. Message Selectors :: Used to attach a filter to a subscription :: Defined using a subset SQL 92 syntax :: JMS selectors :: Filters only message properties :: JMSType = ‘stock’ and trader = ‘bob’ and price < ‘105’ :: XPath selectors :: Filters message bodies that contain XML :: ‘/message/cheese/text() = 'swiss'’ 50
  • 51. Retroactive Consumer :: Used to go back in time :: In terms of messages :: At the start of a subscription, send old messages the consumer may have missed :: Configurable via timed or fixed size recovery 51
  • 52. Slow Consumer Strategies :: Various configurable strategies for handling slow consumers :: Slow consumer situations are very common :: Caused by: :: Slow network connections :: Unreliable network connections :: Busy network situations :: Busy JVM situations :: Half disconnects with sockets 52
  • 53. Use Message Limit Strategies :: PendingMessageLimitStrategy :: Calculates the max number of pending messages to be held in memory for a consumer above its prefetch size :: ConstantPendingMessageLimitStrategy :: A constant limit for all consumers :: PrefetchRatePendingMessageLimitStrategy :: Calculates the max number of pending messages using a multiplier of the consumers prefetch size 53
  • 54. Use Prefetch and an Eviction Policy :: Use the prefetch policy :: The prefetch policy has a property named maximumPendingMessageLimit that can be used on a per connection or per consumer basis :: Use a message eviction policy :: OldestMessageEvictionStrategy :: Evict the oldest messages first :: OldestMessageWithLowestPriorityEvictionStrategy :: Evict the oldest messages with the lowest priority first 54
  • 55. Use Destination Policies :: Configured on the destination policies in the ActiveMQ XML configuration file :: Combined with wildcards, this is very powerful 55
  • 56. Additional Tips :: Consider configuring different message cursors :: The status of slow consumers can be monitored via JMX properties :: discarded - The count of how many messages have been discarded during the lifetime of the subscription due to it being a slow consumer :: matched - The current number of messages matched and to be dispatched to the subscription as soon as some capacity is available in the prefetch buffer. So a non-zero value implies that the prefetch buffer is full for this subscription 56
  • 57. Monitoring :: JMX :: ActiveMQ web console :: Additional consumers :: Camel routes :: SpringSource AMS :: Based on Hyperic :: IONA FuseHQ :: Based on Hyperic 57
  • 59. What is Apache Camel? 59
  • 61. Fluent Java API RouteBuilder MyRoute = new RouteBuilder() { public void configure() { EXAMPLE from("activemq:TEST.QUEUE"). to("file:///Users/bsnyder/camelinbox/text.txt"). to("log:MyLog"); } }; 61
  • 62. XML Config <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> EXAMPLE <package>com.mycompany</package> <route> <from uri="activemq:example.A" /> <to uri="file:///Users/bsnyder/camelinbox/text.txt" /> <to uri=”log:MyLog?showProperties=true” /> </route> </camelContext> 62
  • 63. EIP Pattern: Content Based Router EXAMPLE RouteBuilder builder = new RouteBuilder() { public void configure() { from("seda:a").choice().when(header("foo").isEqualTo("bar ")).to("seda:b") .when(header("foo").isEqualTo("cheese")).to(" seda:c").otherwise().to("seda:d"); } }; 63
  • 64. EIP Pattern: Content Based Router <camelContext id="buildSimpleRouteWithChoice" xmlns="http://activemq.apache.org/camel/schema/spring"> EXAMPLE <route> <from uri="seda:a"/> <choice> <when> <predicate> <header name="foo"/> <isEqualTo value="bar"/> </predicate> <to uri="seda:b"/> </when> <when> <predicate> <header name="foo"/> <isEqualTo value="cheese"/> </predicate> <to uri="seda:c"/> </when> <otherwise><to uri="seda:d"/></otherwise> </choice> </route> </camelContext> 64
  • 65. Do You Have Information Overload Yet? ;-) 65
  • 66. Thank You For Attending! Questions? 66