SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
ActiveMQ in Action:
    Common Problems and Solutions
    Bruce Snyder, Senior Software Engineer, SpringSource/VMware




Friday, July 8, 2011
Common Questions

    •    Should I create my JMS clients from scratch?
    •    How do I manage connections efficiently?
    •    How do I consume only certain messages?
    •    Why is ActiveMQ locking up or freezing?
    •    Do I need a network of brokers?
    •    Should I use a master/slave configuration?




Friday, July 8, 2011
Should I create JMS clients from scratch?




                                                3

Friday, July 8, 2011
Should I create JMS clients from scratch?

    • Question:
           – Would you create a HTTP client from scratch?
           – Would you create a SMTP client from scratch?


    • Answer:
           – Sometimes, but mostly no


    • Solution:
           – Use Spring JMS




                                                            4

Friday, July 8, 2011
Spring JMS




                       5

Friday, July 8, 2011
Spring JMS


                       • JMS Template
                          – Send and receive messages
                            synchronously

                       • Message Listener Container
                          – Receive messages asynchronously
                          – Message-Driven POJOs (MDPs)




                                                              6

Friday, July 8, 2011
Spring JMS


                       • JMS Template
                         – Send and receive messages
                           synchronously

                       • Message Listener Container
                         – Receive messages asynchronously
                         – Message-Driven POJOs (MDPs)




                                                             7

Friday, July 8, 2011
How do I manage connections efficiently?




                                               8

Friday, July 8, 2011
How do I manage connections efficiently?

    • JMS connections are expensive to constantly create and
      destroy
    • Create a group that never closes, i.e., pooling

    • Solutions:
           – ActiveMQ PooledConnectionFactory
           – Spring CachingConnectionFactory




                                                               9

Friday, July 8, 2011
ActiveMQ PooledConnectionFactory

    • Based on Apache Commons Pool
           – Generic object pooling framework from the ASF
    • Highly configurable
           – Instantiate your own custom GenericObjectPool
    • Could be improved
           – Upon hitting pool limit, grow the pool instead of blocking
           – Throw exception when the pool is exhausted
    • Caches JMS Sessions and MessageProducers




                                                                          10

Friday, July 8, 2011
Spring CachingConnectionFactory

    • Based on Spring SingleConnectionFactory
           – Ignores calls to Connection.close()
    • Caches JMS Sessions and MessageProducers
    • By default only one session is cached
           – Increase the sessionCacheSize!
    • Consumers are not closed until Session is closed
           – NOTE: Cache strategy uses the JMS selector as a key




                                                                   11

Friday, July 8, 2011
How do I consume only certain messages?




                                          12

Friday, July 8, 2011
How do I consume only certain messages?

    • ActiveMQ is for sending and receiving events
    • ActiveMQ is NOT a message store

    • Solutions:
           – Use message selectors
           – Correct application design




                                                     13

Friday, July 8, 2011
JMS Selectors

    •    Allows a client to filter messages from a destination
    •    Filters message headers only, not payload
    •    Conditional expressions using a subset of SQL
    •    Provide boolean evaluation of message headers

                                  Booleans TRUE/FALSE; numbers
                                  such as 5, -10, +34; numbers with
                       Literals
                                  decimal or scientific notation such as
                                  43.3E7, +10.5239

                  Identifiers     A header field

                                  AND, OR, LIKE, BETWEEN, =, <>, <,
                  Operators       >, <=, =>, +, =, *, /, IS NULL, IS
                                  NOT NULL

                                                                           14

Friday, July 8, 2011
JMS Selector Examples

         // Select messages with a header named symbol whose value is APPL
         String selector = "symbol = ʻAPPLʼ";

         // Create a consumer that only receives messages about Apple Computer stock
         MessageConsumer consumer =
                 session.createConsumer(someDestination, selector);



         // Select messages with a header named symbol whose value is APPL
         // and with a header named price that is greater than the previous price
         String selector = "symbol = ʻAPPLʼ AND price > " + getPreviousPrice();

         // Create a consumer that only receives messages about Apple Computer stock
         // that has increased in price
         MessageConsumer consumer =
                  session.createConsumer(someDestination, selector);




                                                                                       15

Friday, July 8, 2011
JMS Selectors

    • Very powerful, but like a sharp knife
    • Applied to every message on a destination
           – Can cause unnecessary overhead




                                                  16

Friday, July 8, 2011
Correct Application Design

    • ActiveMQ is for sending and receiving events
    • ActiveMQ is NOT a message store

    • Phase one, consume the messages
           – Lightweight processing
    • Phase two, conduct further processing
           – Heavyweight processing

    • I.e., a proper service-oriented architecture




                                                     17

Friday, July 8, 2011
Why is ActiveMQ is locking up or freezing?




                                             18

Friday, July 8, 2011
Why is ActiveMQ is locking up or freezing?

    •    JVM memory
    •    Broker memory
    •    Prefetch limit
    •    Producer flow control
    •    Message cursors




                                             19

Friday, July 8, 2011
JVM Memory

    • ActiveMQ start script
           – As of 5.4.x JVM is given 256mb of memory (min and max)


    • You may need to increase this!




                                                                      20

Friday, July 8, 2011
Broker Memory

    • ActiveMQ controls how much memory it can use
    • Will not automatically use all the JVM memory
    • Configurable but commented out by default




                                                      21

Friday, July 8, 2011
Broker Memory Example

                  <broker brokerName="myBroker” ...>
                  ...
                    <systemUsage>
                      <systemUsage>
                       <memoryUsage>
                        <memoryUsage limit="64 mb” />
                       </memoryUsage>
                       <storeUsage>
                        <storeUsage limit="100 gb" />
                       </storeUsage>
                       <tempUsage>
                        <tempUsage limit="10 gb" />
                       </tempUsage>
                      </systemUsage>
                    </systemUsage>
                  ...
                  </broker>

                                                        22

Friday, July 8, 2011
Prefetch Limit

    • Prevents a consumer from being flooded with messages
    • Applied on a per client basis

    • Incorrect prefetch limit + slow consumer =
      messages remain in a queue unconsumed

    • Results in some consumers being starved of messages

    • NOTE: Be careful with connection pools




                                                             23

Friday, July 8, 2011
Prefetch Limit Example


   ...
     <bean id="connectionFactory"
       class="org.apache.activemq.ActiveMQConnectionFactory"
       p:brokerURL="tcp://localhost:61616"
       p:prefetchPolicy-ref="prefetchPolicy"/>

     <bean id="prefetchPolicy"
       class="org.apache.activemq.ActiveMQPrefetchPolicy"
       p:queuePrefetch="1" />
   ...




                                                               24

Friday, July 8, 2011
Producer Flow Control

    • Prevents producer from flooding broker
    • If memory exceeds limit, a producer will be paused

    • NOTE: This setting is enabled by default




                                                           25

Friday, July 8, 2011
Broker Memory Example

          <broker brokerName="myBroker” ...>
          ...
          <destinationPolicy>
            <policyMap>
              <policyEntries>
               <policyEntry topic=">" producerFlowControl="true"
                memoryLimit="10mb">
                <pendingSubscriberPolicy>
                 <vmCursor />
                </pendingSubscriberPolicy>
               </policyEntry>
               <policyEntry queue=">" producerFlowControl="true"
                memoryLimit="10mb">
               </policyEntry>
              </policyEntries>
            </policyMap>
          </destinationPolicy>
          ...
          </broker>


                                                                   26

Friday, July 8, 2011
Message Cursors

    • Only so many messages can be held in memory
    • Message cursors provide a configurable message paging

    • Two types of cursors
           – VM cursors
                 • Holds only message reference in memory
           – File cursors
                 • Flushes both message and reference to disk


    • http://activemq.apache.org/how-do-i-configure-activemq-
      to-hold-100s-of-millions-of-queue-messages-.html


                                                                27

Friday, July 8, 2011
Broker Memory Example

          <broker brokerName="myBroker” ...>
          ...
          <destinationPolicy>
            <policyMap>
              <policyEntries>
               <policyEntry topic=">" producerFlowControl="true"
                memoryLimit="10mb">
                <pendingSubscriberPolicy>
                 <vmCursor />
                </pendingSubscriberPolicy>
               </policyEntry>
               <policyEntry queue=">" producerFlowControl="true"
                memoryLimit="10mb">
                <pendingQueuePolicy>
                 <fileQueueCursor />
                </pendingQueuePolicy>
               </policyEntry>
              </policyEntries>
            </policyMap>
          </destinationPolicy>
          ...
          </broker>                                                28

Friday, July 8, 2011
Do I need a network of brokers?




                                      29

Friday, July 8, 2011
Do I need a network of brokers?

    • What is a network of brokers?
           – Clustered ActiveMQ instances
    • How are they clustered?
           – They pass messages between broker instances
           – Send a message to one broker, consume the message from
             a different broker
    • Where might this be useful?
           – Situations where a centralized broker is not suitable
    • How does this work?
           – Using store and forward




                                                                     30

Friday, July 8, 2011
Store and Forward




                        31

Friday, July 8, 2011
Topology Example




                       32

Friday, July 8, 2011
Topology Example




                       33

Friday, July 8, 2011
Topology Example




                       34

Friday, July 8, 2011
Topology Example




                       35

Friday, July 8, 2011
Topology Example




                       36

Friday, July 8, 2011
Should I use a master/slave config?




                                          37

Friday, July 8, 2011
Should I use a master/slave config?

    • What is a master/slave configuration?
           – It helps to provide high availability for ActiveMQ
    • What does that mean?
           – ActiveMQ brokers are configured for warm failover
           – If one broker fails or becomes unreachable, another one
             takes over
    • Where might this be useful?
           – In situations that need highly available message brokers
    • How does this work?
           –




                                                                        38

Friday, July 8, 2011
Types of Master/Slave

    • Shared nothing master/slave
    • Shared storage master/slave
           – Shared database
           – Shared file system




                                    39

Friday, July 8, 2011
Shared Nothing Master/Slave

    • Sometimes called pure master/slave
    • Uses a fully replicated data store
           – Does not depend on database or file system
    • Slave broker consumes all message states from the
      Master broker (messages, acks, tx states)
    • Slave does not start any networking or transport
      connectors
    • Master broker will only respond to client when a message
      exchange has been successfully passed to the slave
      broker



                                                             40

Friday, July 8, 2011
Shared Nothing Master/Slave

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


    • Clients should use failover transport:


     failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false




                                                                             41

Friday, July 8, 2011
Shared Database Master/Slave

    •     Uses tables in a relational database to store data
    •     No restriction on the number of brokers
    •     Simple configuration (JDBC URL)
    •     Clustered database mitigates single point of failure
    •     One master selected at random

    • Clients should use failover transport:

        failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false




                                                                                42

Friday, July 8, 2011
Shared File System Master/Slave

    •     Utilizes a directory on a shared file system to store data
    •     No restriction on number of brokers
    •     Simple configuration (point to the data dir)
    •     Shared file system mitigates single point of failure
    •     One master selected at random

    • Clients should use failover transport:

        failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false




                                                                                43

Friday, July 8, 2011
Thank You!




           Q&A




Friday, July 8, 2011

Weitere ähnliche Inhalte

Was ist angesagt?

Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka IntroductionAmita Mirajkar
 
Introduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisIntroduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisYoshimasa Tanabe
 
Learn O11y from Grafana ecosystem.
Learn O11y from Grafana ecosystem.Learn O11y from Grafana ecosystem.
Learn O11y from Grafana ecosystem.HungWei Chiu
 
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, 2013mumrah
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELKYuHsuan Chen
 
Enterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQEnterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQelliando dias
 
Why Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightWhy Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightKnoldus Inc.
 
Orchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQOrchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQVMware Tanzu
 
Kafka Overview
Kafka OverviewKafka Overview
Kafka Overviewiamtodor
 
Messaging with Spring Integration
Messaging with Spring IntegrationMessaging with Spring Integration
Messaging with Spring IntegrationVadim Mikhnevych
 
Introduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQIntroduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQDmitriy Samovskiy
 
Introduction to blazemeter and jmeter
Introduction to blazemeter and jmeterIntroduction to blazemeter and jmeter
Introduction to blazemeter and jmeterb4usolution .
 
The top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scaleThe top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scaleFlink Forward
 
How to migrate large project from Angular to React
How to migrate large project from Angular to ReactHow to migrate large project from Angular to React
How to migrate large project from Angular to ReactTomasz Bak
 

Was ist angesagt? (20)

Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
Introduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisIntroduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ Artemis
 
Learn O11y from Grafana ecosystem.
Learn O11y from Grafana ecosystem.Learn O11y from Grafana ecosystem.
Learn O11y from Grafana ecosystem.
 
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
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
 
Enterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQEnterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQ
 
kafka
kafkakafka
kafka
 
Why Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightWhy Should we use Microsoft's Playwright
Why Should we use Microsoft's Playwright
 
Message Broker System and RabbitMQ
Message Broker System and RabbitMQMessage Broker System and RabbitMQ
Message Broker System and RabbitMQ
 
Orchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQOrchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQ
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Kafka Overview
Kafka OverviewKafka Overview
Kafka Overview
 
Messaging with Spring Integration
Messaging with Spring IntegrationMessaging with Spring Integration
Messaging with Spring Integration
 
Introduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQIntroduction to AMQP Messaging with RabbitMQ
Introduction to AMQP Messaging with RabbitMQ
 
Introduction to blazemeter and jmeter
Introduction to blazemeter and jmeterIntroduction to blazemeter and jmeter
Introduction to blazemeter and jmeter
 
The top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scaleThe top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scale
 
How to migrate large project from Angular to React
How to migrate large project from Angular to ReactHow to migrate large project from Angular to React
How to migrate large project from Angular to React
 

Andere mochten auch

Advanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQAdvanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQdejanb
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQBruce Snyder
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actiondejanb
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelOmi Om
 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQRob Davies
 
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 BiddulphCarsonified Team
 
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 setupRamakrishna Narkedamilli
 
Introduction to ActiveMQ Apollo
Introduction to ActiveMQ ApolloIntroduction to ActiveMQ Apollo
Introduction to ActiveMQ Apollodejanb
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSBruce Snyder
 
ActiveMQ 5.9.x new features
ActiveMQ 5.9.x new featuresActiveMQ 5.9.x new features
ActiveMQ 5.9.x new featuresChristian Posta
 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQPolyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQChristian Posta
 
Deploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse FabricDeploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse Fabricdejanb
 
ам3. свойства и основные понятия archimate
ам3. свойства и основные понятия archimateам3. свойства и основные понятия archimate
ам3. свойства и основные понятия archimateandvikrub
 
Server load balancer ppt
Server load balancer pptServer load balancer ppt
Server load balancer pptShilpi Tandon
 
Mcollective orchestration tool 소개
Mcollective orchestration tool 소개Mcollective orchestration tool 소개
Mcollective orchestration tool 소개태준 문
 
A Practical Guide for Selecting an Enterprise Messaging Platforms
A Practical Guide for Selecting an Enterprise Messaging PlatformsA Practical Guide for Selecting an Enterprise Messaging Platforms
A Practical Guide for Selecting an Enterprise Messaging PlatformsJesus Rodriguez
 
모바일 개발 트랜드
모바일 개발 트랜드모바일 개발 트랜드
모바일 개발 트랜드Terry Cho
 

Andere mochten auch (20)

Advanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQAdvanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQ
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in action
 
Active MQ
Active MQActive MQ
Active MQ
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQ
 
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
 
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
 
Introduction to ActiveMQ Apollo
Introduction to ActiveMQ ApolloIntroduction to ActiveMQ Apollo
Introduction to ActiveMQ Apollo
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
 
ActiveMQ 5.9.x new features
ActiveMQ 5.9.x new featuresActiveMQ 5.9.x new features
ActiveMQ 5.9.x new features
 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQPolyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQ
 
IBM MQ vs Apache ActiveMQ
IBM MQ vs Apache ActiveMQIBM MQ vs Apache ActiveMQ
IBM MQ vs Apache ActiveMQ
 
Deploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse FabricDeploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse Fabric
 
ам3. свойства и основные понятия archimate
ам3. свойства и основные понятия archimateам3. свойства и основные понятия archimate
ам3. свойства и основные понятия archimate
 
Enterprise mobility
Enterprise mobilityEnterprise mobility
Enterprise mobility
 
Server load balancer ppt
Server load balancer pptServer load balancer ppt
Server load balancer ppt
 
Mcollective orchestration tool 소개
Mcollective orchestration tool 소개Mcollective orchestration tool 소개
Mcollective orchestration tool 소개
 
A Practical Guide for Selecting an Enterprise Messaging Platforms
A Practical Guide for Selecting an Enterprise Messaging PlatformsA Practical Guide for Selecting an Enterprise Messaging Platforms
A Practical Guide for Selecting an Enterprise Messaging Platforms
 
모바일 개발 트랜드
모바일 개발 트랜드모바일 개발 트랜드
모바일 개발 트랜드
 

Ähnlich wie ActiveMQ In Action

ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011Bruce 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 SpringBruce Snyder
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignDATAVERSITY
 
Direct memory jugl-2012.03.08
Direct memory jugl-2012.03.08Direct memory jugl-2012.03.08
Direct memory jugl-2012.03.08Benoit Perroud
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSBruce Snyder
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performancepradeepfn
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan GallimoreJava EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan GallimoreJAX London
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and PerformanceWSO2
 
Membase Meetup - San Diego
Membase Meetup - San DiegoMembase Meetup - San Diego
Membase Meetup - San DiegoMembase
 
Webinar: StorPool and WHIR - better storage, better business
Webinar: StorPool and WHIR - better storage, better businessWebinar: StorPool and WHIR - better storage, better business
Webinar: StorPool and WHIR - better storage, better businessStorPool Storage
 
Introduction to Web Application Clustering
Introduction to Web Application ClusteringIntroduction to Web Application Clustering
Introduction to Web Application ClusteringPiyush Katariya
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]Ryan Cuprak
 
Do we need JMS in 21st century?
Do we need JMS in 21st century?Do we need JMS in 21st century?
Do we need JMS in 21st century?Mikalai Alimenkou
 
Cassandra 2.0 better, faster, stronger
Cassandra 2.0   better, faster, strongerCassandra 2.0   better, faster, stronger
Cassandra 2.0 better, faster, strongerPatrick McFadin
 
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerCassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerDataStax
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!Ulrich Krause
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching SolutionsITviec
 

Ähnlich wie ActiveMQ In Action (20)

ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
 
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
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Direct memory jugl-2012.03.08
Direct memory jugl-2012.03.08Direct memory jugl-2012.03.08
Direct memory jugl-2012.03.08
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMS
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan GallimoreJava EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Membase Meetup - San Diego
Membase Meetup - San DiegoMembase Meetup - San Diego
Membase Meetup - San Diego
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
Webinar: StorPool and WHIR - better storage, better business
Webinar: StorPool and WHIR - better storage, better businessWebinar: StorPool and WHIR - better storage, better business
Webinar: StorPool and WHIR - better storage, better business
 
Introduction to Web Application Clustering
Introduction to Web Application ClusteringIntroduction to Web Application Clustering
Introduction to Web Application Clustering
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
 
Do we need JMS in 21st century?
Do we need JMS in 21st century?Do we need JMS in 21st century?
Do we need JMS in 21st century?
 
Cassandra 2.0 better, faster, stronger
Cassandra 2.0   better, faster, strongerCassandra 2.0   better, faster, stronger
Cassandra 2.0 better, faster, stronger
 
Jms using j boss
Jms using j bossJms using j boss
Jms using j boss
 
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerCassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!
 
Life in the Fast Lane: Full Speed XPages!, #dd13
Life in the Fast Lane: Full Speed XPages!, #dd13Life in the Fast Lane: Full Speed XPages!, #dd13
Life in the Fast Lane: Full Speed XPages!, #dd13
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
 

Mehr von Bruce Snyder

Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringBruce 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 JockeyBruce Snyder
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixBruce Snyder
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a RideBruce Snyder
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 

Mehr von Bruce Snyder (9)

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
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
 
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

The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024TopCSSGallery
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 

Kürzlich hochgeladen (20)

The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 

ActiveMQ In Action

  • 1. ActiveMQ in Action: Common Problems and Solutions Bruce Snyder, Senior Software Engineer, SpringSource/VMware Friday, July 8, 2011
  • 2. Common Questions • Should I create my JMS clients from scratch? • How do I manage connections efficiently? • How do I consume only certain messages? • Why is ActiveMQ locking up or freezing? • Do I need a network of brokers? • Should I use a master/slave configuration? Friday, July 8, 2011
  • 3. Should I create JMS clients from scratch? 3 Friday, July 8, 2011
  • 4. Should I create JMS clients from scratch? • Question: – Would you create a HTTP client from scratch? – Would you create a SMTP client from scratch? • Answer: – Sometimes, but mostly no • Solution: – Use Spring JMS 4 Friday, July 8, 2011
  • 5. Spring JMS 5 Friday, July 8, 2011
  • 6. Spring JMS • JMS Template – Send and receive messages synchronously • Message Listener Container – Receive messages asynchronously – Message-Driven POJOs (MDPs) 6 Friday, July 8, 2011
  • 7. Spring JMS • JMS Template – Send and receive messages synchronously • Message Listener Container – Receive messages asynchronously – Message-Driven POJOs (MDPs) 7 Friday, July 8, 2011
  • 8. How do I manage connections efficiently? 8 Friday, July 8, 2011
  • 9. How do I manage connections efficiently? • JMS connections are expensive to constantly create and destroy • Create a group that never closes, i.e., pooling • Solutions: – ActiveMQ PooledConnectionFactory – Spring CachingConnectionFactory 9 Friday, July 8, 2011
  • 10. ActiveMQ PooledConnectionFactory • Based on Apache Commons Pool – Generic object pooling framework from the ASF • Highly configurable – Instantiate your own custom GenericObjectPool • Could be improved – Upon hitting pool limit, grow the pool instead of blocking – Throw exception when the pool is exhausted • Caches JMS Sessions and MessageProducers 10 Friday, July 8, 2011
  • 11. Spring CachingConnectionFactory • Based on Spring SingleConnectionFactory – Ignores calls to Connection.close() • Caches JMS Sessions and MessageProducers • By default only one session is cached – Increase the sessionCacheSize! • Consumers are not closed until Session is closed – NOTE: Cache strategy uses the JMS selector as a key 11 Friday, July 8, 2011
  • 12. How do I consume only certain messages? 12 Friday, July 8, 2011
  • 13. How do I consume only certain messages? • ActiveMQ is for sending and receiving events • ActiveMQ is NOT a message store • Solutions: – Use message selectors – Correct application design 13 Friday, July 8, 2011
  • 14. JMS Selectors • Allows a client to filter messages from a destination • Filters message headers only, not payload • Conditional expressions using a subset of SQL • Provide boolean evaluation of message headers Booleans TRUE/FALSE; numbers such as 5, -10, +34; numbers with Literals decimal or scientific notation such as 43.3E7, +10.5239 Identifiers A header field AND, OR, LIKE, BETWEEN, =, <>, <, Operators >, <=, =>, +, =, *, /, IS NULL, IS NOT NULL 14 Friday, July 8, 2011
  • 15. JMS Selector Examples // Select messages with a header named symbol whose value is APPL String selector = "symbol = ʻAPPLʼ"; // Create a consumer that only receives messages about Apple Computer stock MessageConsumer consumer = session.createConsumer(someDestination, selector); // Select messages with a header named symbol whose value is APPL // and with a header named price that is greater than the previous price String selector = "symbol = ʻAPPLʼ AND price > " + getPreviousPrice(); // Create a consumer that only receives messages about Apple Computer stock // that has increased in price MessageConsumer consumer = session.createConsumer(someDestination, selector); 15 Friday, July 8, 2011
  • 16. JMS Selectors • Very powerful, but like a sharp knife • Applied to every message on a destination – Can cause unnecessary overhead 16 Friday, July 8, 2011
  • 17. Correct Application Design • ActiveMQ is for sending and receiving events • ActiveMQ is NOT a message store • Phase one, consume the messages – Lightweight processing • Phase two, conduct further processing – Heavyweight processing • I.e., a proper service-oriented architecture 17 Friday, July 8, 2011
  • 18. Why is ActiveMQ is locking up or freezing? 18 Friday, July 8, 2011
  • 19. Why is ActiveMQ is locking up or freezing? • JVM memory • Broker memory • Prefetch limit • Producer flow control • Message cursors 19 Friday, July 8, 2011
  • 20. JVM Memory • ActiveMQ start script – As of 5.4.x JVM is given 256mb of memory (min and max) • You may need to increase this! 20 Friday, July 8, 2011
  • 21. Broker Memory • ActiveMQ controls how much memory it can use • Will not automatically use all the JVM memory • Configurable but commented out by default 21 Friday, July 8, 2011
  • 22. Broker Memory Example <broker brokerName="myBroker” ...> ... <systemUsage> <systemUsage> <memoryUsage> <memoryUsage limit="64 mb” /> </memoryUsage> <storeUsage> <storeUsage limit="100 gb" /> </storeUsage> <tempUsage> <tempUsage limit="10 gb" /> </tempUsage> </systemUsage> </systemUsage> ... </broker> 22 Friday, July 8, 2011
  • 23. Prefetch Limit • Prevents a consumer from being flooded with messages • Applied on a per client basis • Incorrect prefetch limit + slow consumer = messages remain in a queue unconsumed • Results in some consumers being starved of messages • NOTE: Be careful with connection pools 23 Friday, July 8, 2011
  • 24. Prefetch Limit Example ... <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" p:brokerURL="tcp://localhost:61616" p:prefetchPolicy-ref="prefetchPolicy"/> <bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy" p:queuePrefetch="1" /> ... 24 Friday, July 8, 2011
  • 25. Producer Flow Control • Prevents producer from flooding broker • If memory exceeds limit, a producer will be paused • NOTE: This setting is enabled by default 25 Friday, July 8, 2011
  • 26. Broker Memory Example <broker brokerName="myBroker” ...> ... <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" producerFlowControl="true" memoryLimit="10mb"> <pendingSubscriberPolicy> <vmCursor /> </pendingSubscriberPolicy> </policyEntry> <policyEntry queue=">" producerFlowControl="true" memoryLimit="10mb"> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> ... </broker> 26 Friday, July 8, 2011
  • 27. Message Cursors • Only so many messages can be held in memory • Message cursors provide a configurable message paging • Two types of cursors – VM cursors • Holds only message reference in memory – File cursors • Flushes both message and reference to disk • http://activemq.apache.org/how-do-i-configure-activemq- to-hold-100s-of-millions-of-queue-messages-.html 27 Friday, July 8, 2011
  • 28. Broker Memory Example <broker brokerName="myBroker” ...> ... <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" producerFlowControl="true" memoryLimit="10mb"> <pendingSubscriberPolicy> <vmCursor /> </pendingSubscriberPolicy> </policyEntry> <policyEntry queue=">" producerFlowControl="true" memoryLimit="10mb"> <pendingQueuePolicy> <fileQueueCursor /> </pendingQueuePolicy> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> ... </broker> 28 Friday, July 8, 2011
  • 29. Do I need a network of brokers? 29 Friday, July 8, 2011
  • 30. Do I need a network of brokers? • What is a network of brokers? – Clustered ActiveMQ instances • How are they clustered? – They pass messages between broker instances – Send a message to one broker, consume the message from a different broker • Where might this be useful? – Situations where a centralized broker is not suitable • How does this work? – Using store and forward 30 Friday, July 8, 2011
  • 31. Store and Forward 31 Friday, July 8, 2011
  • 32. Topology Example 32 Friday, July 8, 2011
  • 33. Topology Example 33 Friday, July 8, 2011
  • 34. Topology Example 34 Friday, July 8, 2011
  • 35. Topology Example 35 Friday, July 8, 2011
  • 36. Topology Example 36 Friday, July 8, 2011
  • 37. Should I use a master/slave config? 37 Friday, July 8, 2011
  • 38. Should I use a master/slave config? • What is a master/slave configuration? – It helps to provide high availability for ActiveMQ • What does that mean? – ActiveMQ brokers are configured for warm failover – If one broker fails or becomes unreachable, another one takes over • Where might this be useful? – In situations that need highly available message brokers • How does this work? – 38 Friday, July 8, 2011
  • 39. Types of Master/Slave • Shared nothing master/slave • Shared storage master/slave – Shared database – Shared file system 39 Friday, July 8, 2011
  • 40. Shared Nothing Master/Slave • Sometimes called pure master/slave • Uses a fully replicated data store – Does not depend on database or file system • Slave broker consumes all message states from the Master broker (messages, acks, tx states) • Slave does not start any networking or transport connectors • Master broker will only respond to client when a message exchange has been successfully passed to the slave broker 40 Friday, July 8, 2011
  • 41. Shared Nothing Master/Slave • If the master fails, the slave optionally has two modes of operation: 1. Start up all it’s network and transport connectors • All clients connected to failed Master resume on Slave 2. Close down completely • Slave is simply used to duplicate state from Master • Clients should use failover transport: failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false 41 Friday, July 8, 2011
  • 42. Shared Database Master/Slave • Uses tables in a relational database to store data • No restriction on the number of brokers • Simple configuration (JDBC URL) • Clustered database mitigates single point of failure • One master selected at random • Clients should use failover transport: failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false 42 Friday, July 8, 2011
  • 43. Shared File System Master/Slave • Utilizes a directory on a shared file system to store data • No restriction on number of brokers • Simple configuration (point to the data dir) • Shared file system mitigates single point of failure • One master selected at random • Clients should use failover transport: failover://(tcp://masterhost:61616, tcp://slavehost:61616)?randomize=false 43 Friday, July 8, 2011
  • 44. Thank You! Q&A Friday, July 8, 2011