The chapter introduces the book’s example applications and explains that they are designed to demonstrate ActiveMQ’s JMS capabilities in a practical, business-like way. Instead of relying only on the simpler samples that ship with ActiveMQ, the book uses two richer scenarios: a stock portfolio system and a job processing system. These examples are meant to be revisited throughout the book as the reader learns more about messaging features and how ActiveMQ extends the JMS specification.
A major part of the chapter is devoted to setting up the environment for running the examples. It walks through downloading and installing Maven, verifying the installation, ensuring an Internet connection for dependency downloads, and compiling the source code with Maven. It also explains how the examples are executed with the Maven exec plugin, and how Maven may fetch required artifacts through a local repository manager during the first run.
The two sample applications highlight the difference between publish/subscribe and point-to-point messaging. In the stock portfolio example, a publisher sends stock price updates to topics and subscribed consumers receive copies of each message, so the consumers must be running to catch the updates. In the job queue example, a producer sends work messages to queues and consumers process them one at a time, with the broker holding messages until they can be delivered. Together, these examples show how ActiveMQ supports both messaging styles and prepare the reader for more advanced uses later in the book.
ActiveMQ implements all the features from the JMS specification, as well as many additional features.
The stock portfolio example uses topics to deliver every message to every consumer on a destination.
The job queue example uses queues to deliver one message to each consumer on a destination in a round-robin fashion.
FAQ
What is the main purpose of Chapter 3 in ActiveMQ in Action?Chapter 3 introduces the book’s example applications and shows how to compile and run them with Maven and ActiveMQ. It also explains the two main use cases used throughout the book: a stock portfolio example and a job queue example.Why does the chapter use a stock portfolio example?The stock portfolio example is used to demonstrate publish/subscribe messaging. It shows how publishers broadcast stock price updates to topics and how subscribed consumers receive those messages asynchronously.Why does the chapter use a job queue example?The job queue example is used to demonstrate point-to-point messaging. It shows how producers send job messages to queues and how consumers process those messages one at a time in a round-robin style.What is the difference between topics and queues in the examples?Topics are used for pub/sub messaging, where every active subscriber gets a copy of each message. Queues are used for point-to-point messaging, where each message is delivered to only one consumer.What tools do you need to compile and run the examples?You need Maven installed and an ActiveMQ broker available. The chapter explains how to use Maven to compile the source and run the example applications from the command line.What are the basic steps to run the stock portfolio example?First start ActiveMQ, then run the Consumer class, and finally run the Publisher class. The consumer should start before the publisher so it can receive all published topic messages.Why must the stock portfolio consumer start before the publisher?Because the stock portfolio example uses non-durable topic subscriptions. If the consumer is not active when messages are published, it may miss them since topics do not store messages for inactive subscribers.What are the basic steps to run the job queue example?First start ActiveMQ, then run the Producer class, and then run the Consumer class. Unlike the topic example, the producer can run before the consumer because queues hold messages until they are consumed.How many messages do the example applications send?Both examples are designed to send 1,000 messages total. They send messages in blocks of 10 to show message flow more clearly during execution.Why does Maven download artifacts from localhost in the examples?The chapter shows Maven using a local Nexus repository manager on localhost. Nexus acts as a proxy cache for remote repositories, so Maven downloads dependencies through it and later reuses the cached artifacts for faster builds.
pro $24.99 per month
access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!