652 lines
34 KiB
Plaintext
652 lines
34 KiB
Plaintext
= Examples
|
|
:idprefix:
|
|
:idseparator: -
|
|
|
|
The Apache ActiveMQ Artemis Examples repository contains over 90 examples demonstrating many of the client and broker features.
|
|
|
|
The examples can be found at: https://github.com/apache/activemq-artemis-examples[https://github.com/apache/activemq-artemis-examples^]
|
|
|
|
The individual examples are available under the `examples` directory, and are grouped within the following sub tree:
|
|
|
|
* `features` - Examples containing broker specific features.
|
|
** `clustered` - examples showing load balancing and distribution capabilities.
|
|
** `ha` - examples showing failover and reconnection capabilities.
|
|
** `perf` - examples allowing you to run a few performance tests on the server
|
|
** `standard` - examples demonstrating various broker features.
|
|
** `sub-modules` - examples of integrated external modules.
|
|
* `protocols` - Protocol specific examples
|
|
** `amqp`
|
|
** `mqtt`
|
|
** `openwire`
|
|
** `stomp`
|
|
|
|
== Running the Examples
|
|
|
|
First, run `mvn clean package` in the repository root to prepare a broker distribution in the artemis-distribution/target directory for use by the examples.
|
|
|
|
To run any example, simply `cd` into the appropriate example directory and type `mvn verify` or `mvn install` (For details please read the readme.md in each example directory).
|
|
|
|
You can use the profile `-Pexamples` to run multiple examples under any example tree.
|
|
|
|
For each example, you will have a created server under `./target/server0` (some examples use more than one server).
|
|
|
|
You have the option to prevent the example from starting the server (e.g. if you want to start the server manually) by simply specifying the `-PnoServer` profile, e.g.:
|
|
|
|
[,sh]
|
|
----
|
|
# running an example without running the server
|
|
mvn verify -PnoServer
|
|
----
|
|
|
|
Also under `./target` there will be a script repeating the commands to create each server.
|
|
Here is the `create-server0.sh` generated by the `Queue` example.
|
|
This is useful to see exactly what command(s) are required to configure the server(s).
|
|
|
|
[,sh]
|
|
----
|
|
# These are the commands used to create server0
|
|
/myInstallDirectory/apache-artemis/bin/artemis create --allow-anonymous --silent --force --no-web --user guest --password guest --role guest --port-offset 0 --data ./data --allow-anonymous --no-autotune --verbose /myInstallDirectory/apache-artemis-1.1.0/examples/features/standard/queue/target/server0
|
|
----
|
|
|
|
Several examples use UDP clustering which may not work in your environment by default.
|
|
On linux the command would be:
|
|
|
|
[,sh]
|
|
----
|
|
route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
|
|
----
|
|
|
|
This command should be run as root.
|
|
This will redirect any traffic directed to `224.0.0.0` to the loopback interface.
|
|
On Mac OS X, the command is slightly different:
|
|
|
|
[,sh]
|
|
----
|
|
sudo route add 224.0.0.0 127.0.0.1 -netmask 240.0.0.0
|
|
----
|
|
|
|
All the examples use the xref:maven-plugin.adoc#maven-plugins[Maven plugin], which can be useful for running your test servers as well.
|
|
|
|
This is the common output when running an example.
|
|
On this case taken from the `Queue` example:
|
|
|
|
[,sh]
|
|
----
|
|
[INFO] -------------< org.apache.activemq.examples.broker:queue >--------------
|
|
[INFO] Building ActiveMQ Artemis JMS Queue Example 2.32.0
|
|
[INFO] from pom.xml
|
|
[INFO] --------------------------------[ jar ]---------------------------------
|
|
[INFO]
|
|
[INFO] --- enforcer:3.3.0:enforce (enforce-maven-version) @ queue ---
|
|
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
|
|
[INFO]
|
|
[INFO] --- enforcer:3.3.0:enforce (enforce-java-version) @ queue ---
|
|
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
|
|
[INFO]
|
|
[INFO] --- remote-resources:3.1.0:process (process-resource-bundles) @ queue ---
|
|
[INFO] Preparing remote bundle org.apache.apache.resources:apache-jar-resource-bundle:1.5
|
|
[INFO] Copying 3 resources from 1 bundle.
|
|
[INFO]
|
|
[INFO] --- resources:3.3.1:resources (default-resources) @ queue ---
|
|
[INFO] Copying 1 resource from src/main/resources to target/classes
|
|
[INFO] Copying 3 resources from target/maven-shared-archive-resources to target/classes
|
|
[INFO]
|
|
[INFO] --- compiler:3.11.0:compile (default-compile) @ queue ---
|
|
[INFO] Changes detected - recompiling the module! :source
|
|
[INFO] Compiling 1 source file with javac [debug target 11] to target/classes
|
|
[INFO]
|
|
[INFO] --- resources:3.3.1:testResources (default-testResources) @ queue ---
|
|
[INFO] skip non existing resourceDirectory /home/user/activemq-artemis-examples/examples/features/standard/queue/src/test/resources
|
|
[INFO] Copying 3 resources from target/maven-shared-archive-resources to target/test-classes
|
|
[INFO]
|
|
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ queue ---
|
|
[INFO] No sources to compile
|
|
[INFO]
|
|
[INFO] --- surefire:2.22.2:test (default-test) @ queue ---
|
|
[INFO]
|
|
[INFO] --- jar:3.3.0:jar (default-jar) @ queue ---
|
|
[INFO] Building jar: /home/user/activemq-artemis-examples/examples/features/standard/queue/target/queue-2.32.0.jar
|
|
[INFO]
|
|
[INFO] --- site:3.12.1:attach-descriptor (attach-descriptor) @ queue ---
|
|
[INFO] Skipping because packaging 'jar' is not pom.
|
|
[INFO]
|
|
[INFO] --- source:3.3.0:jar-no-fork (attach-sources) @ queue ---
|
|
[INFO] Building jar: /home/user/activemq-artemis-examples/examples/features/standard/queue/target/queue-2.32.0-sources.jar
|
|
[INFO]
|
|
[INFO] --- artemis:2.32.0:create (create) @ queue ---
|
|
[INFO]
|
|
[INFO] --- artemis:2.32.0:cli (start) @ queue ---
|
|
[INFO] awaiting server to start
|
|
server-out: _ _ _
|
|
server-out: / \ ____| |_ ___ __ __(_) _____
|
|
server-out: / _ \| _ \ __|/ _ \ \/ | |/ __/
|
|
server-out: / ___ \ | \/ |_/ __/ |\/| | |\___ \
|
|
server-out: /_/ \_\| \__\____|_| |_|_|/___ /
|
|
server-out: Apache ActiveMQ Artemis 2.32.0
|
|
server-out:
|
|
server-out:
|
|
[INFO] awaiting server to start
|
|
server-out:2023-12-14 14:33:06,314 INFO [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server version 2.32.0
|
|
server-out:2023-12-14 14:33:06,339 INFO [org.apache.activemq.artemis.core.server] AMQ221000: primary Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=./data/journal,bindingsDirectory=./data/bindings,largeMessagesDirectory=./data/large-messages,pagingDirectory=./data/paging)
|
|
server-out:2023-12-14 14:33:06,354 INFO [org.apache.activemq.artemis.core.server] AMQ221012: Using AIO Journal
|
|
server-out:2023-12-14 14:33:06,380 INFO [org.apache.activemq.artemis.core.server] AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 1073741824
|
|
server-out:2023-12-14 14:33:06,391 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
|
|
server-out:2023-12-14 14:33:06,391 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
|
|
server-out:2023-12-14 14:33:06,391 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
|
|
server-out:2023-12-14 14:33:06,392 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT
|
|
server-out:2023-12-14 14:33:06,392 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-openwire-protocol]. Adding protocol support for: OPENWIRE
|
|
server-out:2023-12-14 14:33:06,392 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
|
|
server-out:2023-12-14 14:33:06,411 INFO [org.apache.activemq.artemis.core.server] AMQ221034: Waiting indefinitely to obtain primary lock
|
|
server-out:2023-12-14 14:33:06,411 INFO [org.apache.activemq.artemis.core.server] AMQ221035: Primary Server Obtained primary lock
|
|
server-out:2023-12-14 14:33:06,450 INFO [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address DLQ supporting [ANYCAST]
|
|
server-out:2023-12-14 14:33:06,454 INFO [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue DLQ on address DLQ
|
|
server-out:2023-12-14 14:33:06,476 INFO [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST]
|
|
server-out:2023-12-14 14:33:06,476 INFO [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue
|
|
server-out:2023-12-14 14:33:06,681 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61616 for protocols [CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE]
|
|
server-out:2023-12-14 14:33:06,683 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP]
|
|
server-out:2023-12-14 14:33:06,685 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5672 for protocols [AMQP]
|
|
server-out:2023-12-14 14:33:06,687 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:1883 for protocols [MQTT]
|
|
server-out:2023-12-14 14:33:06,689 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61613 for protocols [STOMP]
|
|
server-out:2023-12-14 14:33:06,690 INFO [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live
|
|
server-out:2023-12-14 14:33:06,690 INFO [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.32.0 [0.0.0.0, nodeID=b20d82dd-9a8d-11ee-a56d-000c2997e711]
|
|
[INFO] Server started
|
|
[INFO]
|
|
[INFO] --- artemis:2.32.0:runClient (runClient) @ queue ---
|
|
Sent message: This is a text message
|
|
Received message: This is a text message
|
|
[INFO]
|
|
[INFO] --- artemis:2.32.0:stop (stop) @ queue ---
|
|
server-out:2023-12-14 14:33:08,295 INFO [org.apache.activemq.artemis.core.server] AMQ221002: Apache ActiveMQ Artemis Message Broker version 2.32.0 [b20d82dd-9a8d-11ee-a56d-000c2997e711] stopped, uptime 1.969 seconds
|
|
server-out:Server stopped!
|
|
[INFO] ------------------------------------------------------------------------
|
|
[INFO] BUILD SUCCESS
|
|
[INFO] ------------------------------------------------------------------------
|
|
[INFO] Total time: 4.845 s
|
|
[INFO] Finished at: 2023-12-14T14:33:08Z
|
|
[INFO] ------------------------------------------------------------------------
|
|
----
|
|
|
|
This list includes a preview of some examples that exist for Artemis in the https://github.com/apache/activemq-artemis-examples[Examples Repository^], see the repository for more.
|
|
|
|
== Application-Layer Failover
|
|
|
|
Apache ActiveMQ Artemis also supports Application-Layer failover, useful in the case that replication is not enabled on the server side.
|
|
|
|
With Application-Layer failover, it's up to the application to register a JMS `ExceptionListener` with Apache ActiveMQ Artemis which will be called by Apache ActiveMQ Artemis in the event that connection failure is detected.
|
|
|
|
The code in the `ExceptionListener` then recreates the JMS connection, session, etc on another node and the application can continue.
|
|
|
|
Application-layer failover is an alternative approach to High Availability (HA).
|
|
Application-layer failover differs from automatic failover in that some client side coding is required in order to implement this.
|
|
Also, with Application-layer failover, since the old session object dies and a new one is created, any uncommitted work in the old session will be lost, and any unacknowledged messages might be redelivered.
|
|
|
|
== Core Bridge Example
|
|
|
|
The `bridge` example demonstrates a core bridge deployed on one server, which consumes messages from a local queue and forwards them to an address on a second server.
|
|
|
|
Core bridges are used to create message flows between any two Apache ActiveMQ Artemis servers which are remotely separated.
|
|
Core bridges are resilient and will cope with temporary connection failure allowing them to be an ideal choice for forwarding over unreliable connections, e.g. a WAN.
|
|
|
|
== Browser
|
|
|
|
The `browser` example shows you how to use a JMS `QueueBrowser` with Apache ActiveMQ Artemis.
|
|
|
|
Queues are a standard part of JMS, please consult the JMS 2.0 specification for full details.
|
|
|
|
A `QueueBrowser` is used to look at messages on the queue without removing them.
|
|
It can scan the entire content of a queue or only messages matching a message selector.
|
|
|
|
== Camel
|
|
|
|
The `camel` example demonstrates how to build and deploy a Camel route to the broker using a web application archive (i.e. `war` file).
|
|
|
|
== Client Kickoff
|
|
|
|
The `client-kickoff` example shows how to terminate client connections given an IP address using the JMX management API.
|
|
|
|
== Client side failover listener
|
|
|
|
The `client-side-failoverlistener` example shows how to register a listener to monitor failover events
|
|
|
|
== Client-Side Load-Balancing
|
|
|
|
The `client-side-load-balancing` example demonstrates how sessions created from a single JMS `Connection` can be created to different nodes of the cluster.
|
|
In other words it demonstrates how Apache ActiveMQ Artemis does client-side load-balancing of sessions across the cluster.
|
|
|
|
== Clustered Durable Subscription
|
|
|
|
This example demonstrates a clustered JMS durable subscription
|
|
|
|
== Clustered Grouping
|
|
|
|
This is similar to the message grouping example except that it demonstrates it working over a cluster.
|
|
Messages sent to different nodes with the same group id will be sent to the same node and the same consumer.
|
|
|
|
== Clustered Queue
|
|
|
|
The `clustered-queue` example demonstrates a queue deployed on two different nodes.
|
|
The two nodes are configured to form a cluster.
|
|
We then create a consumer for the queue on each node, and we create a producer on only one of the nodes.
|
|
We then send some messages via the producer, and we verify that both consumers receive the sent messages in a round-robin fashion.
|
|
|
|
== Clustering with JGroups
|
|
|
|
The `clustered-jgroups` example demonstrates how to form a two node cluster using JGroups as its underlying topology discovery technique, rather than the default UDP broadcasting.
|
|
We then create a consumer for the queue on each node, and we create a producer on only one of the nodes.
|
|
We then send some messages via the producer, and we verify that both consumers receive the sent messages in a round-robin fashion.
|
|
|
|
== Clustered Standalone
|
|
|
|
The `clustered-standalone` example demonstrates how to configure and starts 3 cluster nodes on the same machine to form a cluster.
|
|
A subscriber for a JMS topic is created on each node, and we create a producer on only one of the nodes.
|
|
We then send some messages via the producer, and we verify that the 3 subscribers receive all the sent messages.
|
|
|
|
== Clustered Static Discovery
|
|
|
|
This example demonstrates how to configure a cluster using a list of connectors rather than UDP for discovery
|
|
|
|
== Clustered Static Cluster One Way
|
|
|
|
This example demonstrates how to set up a cluster where cluster connections are one way, i.e. server A \-> Server B \-> Server C
|
|
|
|
== Clustered Topic
|
|
|
|
The `clustered-topic` example demonstrates a JMS topic deployed on two different nodes.
|
|
The two nodes are configured to form a cluster.
|
|
We then create a subscriber on the topic on each node, and we create a producer on only one of the nodes.
|
|
We then send some messages via the producer, and we verify that both subscribers receive all the sent messages.
|
|
|
|
== Message Consumer Rate Limiting
|
|
|
|
With Apache ActiveMQ Artemis you can specify a maximum consume rate at which a JMS MessageConsumer will consume messages.
|
|
This can be specified when creating or deploying the connection factory.
|
|
|
|
If this value is specified then Apache ActiveMQ Artemis will ensure that messages are never consumed at a rate higher than the specified rate.
|
|
This is a form of consumer throttling.
|
|
|
|
== Dead Letter
|
|
|
|
The `dead-letter` example shows you how to define and deal with dead letter messages.
|
|
Messages can be delivered unsuccessfully (e.g. if the transacted session used to consume them is rolled back).
|
|
|
|
Such a message goes back to the JMS destination ready to be redelivered.
|
|
However, this means it is possible for a message to be delivered again and again without any success and remain in the destination, clogging the system.
|
|
|
|
To prevent this, messaging systems define dead letter messages: after a specified unsuccessful delivery attempts, the message is removed from the destination and put instead in a dead letter destination where they can be consumed for further investigation.
|
|
|
|
== Delayed Redelivery
|
|
|
|
The `delayed-redelivery` example demonstrates how Apache ActiveMQ Artemis can be configured to provide a delayed redelivery in the case a message needs to be redelivered.
|
|
|
|
Delaying redelivery can often be useful in the case that clients regularly fail or roll-back.
|
|
Without a delayed redelivery, the system can get into a "thrashing" state, with delivery being attempted, the client rolling back, and delivery being re-attempted in quick succession, using up valuable CPU and network resources.
|
|
|
|
== Divert
|
|
|
|
Apache ActiveMQ Artemis diverts allow messages to be transparently "diverted" or copied from one address to another with just some simple configuration defined on the server side.
|
|
|
|
== Durable Subscription
|
|
|
|
The `durable-subscription` example shows you how to use a durable subscription with Apache ActiveMQ Artemis.
|
|
Durable subscriptions are a standard part of JMS, please consult the JMS 1.1 specification for full details.
|
|
|
|
Unlike non-durable subscriptions, the key function of durable subscriptions is that the messages contained in them persist longer than the lifetime of the subscriber - i.e. they will accumulate messages sent to the topic even if there is no active subscriber on them.
|
|
They will also survive server restarts or crashes.
|
|
Note that for the messages to be persisted, the messages sent to them must be marked as durable messages.
|
|
|
|
== Embedded
|
|
|
|
The `embedded` example shows how to embed a broker within your own code using POJO instantiation and no config files.
|
|
|
|
== Embedded Simple
|
|
|
|
The `embedded-simple` example shows how to embed a broker within your own code using regular Apache ActiveMQ Artemis XML files.
|
|
|
|
== Exclusive Queue
|
|
|
|
The `exlusive-queue` example shows you how to use exclusive queues, that route all messages to only one consumer at a time.
|
|
|
|
== Message Expiration
|
|
|
|
The `expiry` example shows you how to define and deal with message expiration.
|
|
Messages can be retained in the messaging system for a limited period of time before being removed.
|
|
JMS specification states that clients should not receive messages that have been expired (but it does not guarantee this will not happen).
|
|
|
|
Apache ActiveMQ Artemis can assign an expiry address to a given queue so that when messages are expired, they are removed from the queue and sent to the expiry address.
|
|
These "expired" messages can later be consumed from the expiry address for further inspection.
|
|
|
|
== Apache ActiveMQ Artemis Resource Adapter example
|
|
|
|
This examples shows how to build the activemq resource adapters a rar for deployment in other Application Server's
|
|
|
|
== HTTP Transport
|
|
|
|
The `http-transport` example shows you how to configure Apache ActiveMQ Artemis to use the HTTP protocol as its transport layer.
|
|
|
|
== Instantiate JMS Objects Directly
|
|
|
|
Usually, JMS Objects such as `ConnectionFactory`, `Queue` and `Topic` instances are looked up from JNDI before being used by the client code.
|
|
This objects are called "administered objects" in JMS terminology.
|
|
|
|
However, in some cases a JNDI server may not be available or desired.
|
|
To come to the rescue Apache ActiveMQ Artemis also supports the direct instantiation of these administered objects on the client side so you don't have to use JNDI for JMS.
|
|
|
|
== Interceptor
|
|
|
|
Apache ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system.
|
|
Interceptors allow you to handle various message events in Apache ActiveMQ Artemis.
|
|
|
|
== Interceptor AMQP
|
|
|
|
Similar to the <<#interceptor,Interceptor>> example, but using AMQP interceptors.
|
|
|
|
== Interceptor Client
|
|
|
|
Similar to the <<#interceptor,Interceptor>> example, but using interceptors on the *client* rather than the broker.
|
|
|
|
== Interceptor MQTT
|
|
|
|
Similar to the <<#interceptor,Interceptor>> example, but using MQTT interceptors.
|
|
|
|
== JAAS
|
|
|
|
The `jaas` example shows you how to configure Apache ActiveMQ Artemis to use JAAS for security.
|
|
Apache ActiveMQ Artemis can leverage JAAS to delegate user authentication and authorization to existing security infrastructure.
|
|
|
|
== JMS Auto Closable
|
|
|
|
The `jms-auto-closeable` example shows how JMS resources, such as connections, sessions and consumers, in JMS 2 can be automatically closed on error.
|
|
|
|
== JMS Completion Listener
|
|
|
|
The `jms-completion-listener` example shows how to send a message asynchronously to Apache ActiveMQ Artemis and use a CompletionListener to be notified of the Broker receiving it.
|
|
|
|
== JMS Bridge
|
|
|
|
The `jms-bridge` example shows how to setup a bridge between two standalone Apache ActiveMQ Artemis servers.
|
|
|
|
== JMS Context
|
|
|
|
The `jms-context` example shows how to send and receive a message to/from an address/queue using Apache ActiveMQ Artemis by using a JMS Context.
|
|
|
|
A JMSContext is part of JMS 2.0 and combines the JMS Connection and Session Objects into a simple Interface.
|
|
|
|
== JMS Shared Consumer
|
|
|
|
The `jms-shared-consumer` example shows you how can use shared consumers to share a subscription on a topic.
|
|
In JMS 1.1 this was not allowed and so caused a scalability issue.
|
|
In JMS 2 this restriction has been lifted so you can share the load across different threads and connections.
|
|
|
|
== JMX Management
|
|
|
|
The `jmx` example shows how to manage Apache ActiveMQ Artemis using JMX.
|
|
|
|
== Large Message
|
|
|
|
The `large-message` example shows you how to send and receive very large messages with Apache ActiveMQ Artemis.
|
|
Apache ActiveMQ Artemis supports the sending and receiving of huge messages, much larger than can fit in available RAM on the client or server.
|
|
Effectively the only limit to message size is the amount of disk space you have on the server.
|
|
|
|
Large messages are persisted on the server so they can survive a server restart.
|
|
In other words Apache ActiveMQ Artemis doesn't just do a simple socket stream from the sender to the consumer.
|
|
|
|
== Last-Value Queue
|
|
|
|
The `last-value-queue` example shows you how to define and deal with last-value queues.
|
|
Last-value queues are special queues which discard any messages when a newer message with the same value for a well-defined last-value property is put in the queue.
|
|
In other words, a last-value queue only retains the last value.
|
|
|
|
A typical example for last-value queue is for stock prices, where you are only interested by the latest price for a particular stock.
|
|
|
|
== Management
|
|
|
|
The `management` example shows how to manage Apache ActiveMQ Artemis using JMS Messages to invoke management operations on the server.
|
|
|
|
== Management Notification
|
|
|
|
The `management-notification` example shows how to receive management notifications from Apache ActiveMQ Artemis using JMS messages.
|
|
Apache ActiveMQ Artemis servers emit management notifications when events of interest occur (consumers are created or closed, addresses are created or deleted, security authentication fails, etc.).
|
|
|
|
== Message Counter
|
|
|
|
The `message-counters` example shows you how to use message counters to obtain message information for a queue.
|
|
|
|
== Message Group
|
|
|
|
The `message-group` example shows you how to configure and use message groups with Apache ActiveMQ Artemis.
|
|
Message groups allow you to pin messages so they are only consumed by a single consumer.
|
|
Message groups are sets of messages that has the following characteristics:
|
|
|
|
* Messages in a message group share the same group id, i.e. they have same JMSXGroupID string property values
|
|
* The consumer that receives the first message of a group will receive all the messages that belongs to the group
|
|
|
|
== Message Group
|
|
|
|
The `message-group2` example shows you how to configure and use message groups with Apache ActiveMQ Artemis via a connection factory.
|
|
|
|
== Message Priority
|
|
|
|
Message Priority can be used to influence the delivery order for messages.
|
|
|
|
It can be retrieved by the message's standard header field 'JMSPriority' as defined in JMS specification version 1.1.
|
|
|
|
The value is of type integer, ranging from 0 (the lowest) to 9 (the highest).
|
|
When messages are being delivered, their priorities will effect their order of delivery.
|
|
Messages of higher priorities will likely be delivered before those of lower priorities.
|
|
|
|
Messages of equal priorities are delivered in the natural order of their arrival at their destinations.
|
|
Please consult the JMS 1.1 specification for full details.
|
|
|
|
== Multiple Failover
|
|
|
|
This example demonstrates how to set up a primary server with multiple backups
|
|
|
|
== Multiple Failover Failback
|
|
|
|
This example demonstrates how to set up a primary server with multiple backups but forcing failover back to the original primary server
|
|
|
|
== No Consumer Buffering
|
|
|
|
By default, Apache ActiveMQ Artemis consumers buffer messages from the server in a client side buffer before you actually receive them on the client side.
|
|
This improves performance since otherwise every time you called receive() or had processed the last message in a `MessageListener onMessage()` method, the Apache ActiveMQ Artemis client would have to go the server to request the next message, which would then get sent to the client side, if one was available.
|
|
|
|
This would involve a network round trip for every message and reduce performance.
|
|
Therefore, by default, Apache ActiveMQ Artemis pre-fetches messages into a buffer on each consumer.
|
|
|
|
In some case buffering is not desirable, and Apache ActiveMQ Artemis allows it to be switched off.
|
|
This example demonstrates that.
|
|
|
|
== Non-Transaction Failover With Server Data Replication
|
|
|
|
The `non-transaction-failover` example demonstrates two servers coupled as a live-backup pair for high availability (HA), and a client using a _non-transacted_ JMS session failing over from primary to backup when the primary server is crashed.
|
|
|
|
Apache ActiveMQ Artemis implements failover of client connections between primary and backup servers.
|
|
This is implemented by the replication of state between primary and backup nodes.
|
|
When replication is configured and a primary node crashes, the client connections can carry on and continue to send and consume messages.
|
|
When non-transacted sessions are used, once and only once message delivery is not guaranteed and it is possible that some messages will be lost or delivered twice.
|
|
|
|
== OpenWire
|
|
|
|
The `Openwire` example shows how to configure an Apache ActiveMQ Artemis server to communicate with an Apache ActiveMQ Artemis JMS client that uses open-wire protocol.
|
|
|
|
You will find the queue example for open wire, and the chat example.
|
|
The virtual-topic-mapping examples shows how to map the ActiveMQ Classic Virtual Topic naming convention to work with the Artemis Address model.
|
|
|
|
== Paging
|
|
|
|
The `paging` example shows how Apache ActiveMQ Artemis can support huge queues even when the server is running in limited RAM.
|
|
It does this by transparently _paging_ messages to disk, and _depaging_ them when they are required.
|
|
|
|
== Pre-Acknowledge
|
|
|
|
Standard JMS supports three acknowledgement modes:`` AUTO_ACKNOWLEDGE``, `CLIENT_ACKNOWLEDGE`, and `DUPS_OK_ACKNOWLEDGE`.
|
|
For a full description on these modes please consult the JMS specification, or any JMS tutorial.
|
|
|
|
All of these standard modes involve sending acknowledgements from the client to the server.
|
|
However in some cases, you really don't mind losing messages in event of failure, so it would make sense to acknowledge the message on the server before delivering it to the client.
|
|
This example demonstrates how Apache ActiveMQ Artemis allows this with an extra acknowledgement mode.
|
|
|
|
== Message Producer Rate Limiting
|
|
|
|
The `producer-rte-limit` example demonstrates how, with Apache ActiveMQ Artemis, you can specify a maximum send rate at which a JMS message producer will send messages.
|
|
|
|
== Queue
|
|
|
|
A simple example demonstrating a queue.
|
|
|
|
== Message Redistribution
|
|
|
|
The `queue-message-redistribution` example demonstrates message redistribution between queues with the same name deployed in different nodes of a cluster.
|
|
|
|
== Queue Requestor
|
|
|
|
A simple example demonstrating a JMS queue requestor.
|
|
|
|
== Queue with Message Selector
|
|
|
|
The `queue-selector` example shows you how to selectively consume messages using message selectors with queue consumers.
|
|
|
|
== Reattach Node example
|
|
|
|
The `Reattach Node` example shows how a client can try to reconnect to the same server instead of failing the connection immediately and notifying any user ExceptionListener objects.
|
|
Apache ActiveMQ Artemis can be configured to automatically retry the connection, and reattach to the server when it becomes available again across the network.
|
|
|
|
== Replicated Failback example
|
|
|
|
An example showing how failback works when using replication. In this example a primary server will replicate all its Journal to a backup server as it updates it.
|
|
When the primary server crashes the backup takes over from the primary server and the client reconnects and carries on from where it left off.
|
|
|
|
== Replicated Failback static example
|
|
|
|
An example showing how failback works when using replication, but this time with static connectors
|
|
|
|
== Replicated multiple failover example
|
|
|
|
An example showing how to configure multiple backups when using replication
|
|
|
|
== Replicated Failover transaction example
|
|
|
|
An example showing how failover works with a transaction when using replication
|
|
|
|
== Request-Reply example
|
|
|
|
A simple example showing the JMS request-response pattern.
|
|
|
|
== Scheduled Message
|
|
|
|
The `scheduled-message` example shows you how to send a scheduled message to an address/queue with Apache ActiveMQ Artemis.
|
|
Scheduled messages won't get delivered until a specified time in the future.
|
|
|
|
== Security
|
|
|
|
The `security` example shows you how configure and use role based security with Apache ActiveMQ Artemis.
|
|
|
|
== Security LDAP
|
|
|
|
The `security-ldap` example shows you how configure and use role based security with Apache ActiveMQ Artemis & an embedded instance of the Apache DS LDAP server.
|
|
|
|
== Security keycloak
|
|
|
|
The `security-keycloak` example shows you how to delegate security with Apache ActiveMQ Artemis & an external Keycloak.
|
|
Using OAuth of the web console and direct access for JMS clients.
|
|
|
|
== Send Acknowledgements
|
|
|
|
The `send-acknowledgements` example shows you how to use Apache ActiveMQ Artemis's advanced _asynchronous send acknowledgements_ feature to obtain acknowledgement from the server that sends have been received and processed in a separate stream to the sent messages.
|
|
|
|
== Slow Consumer
|
|
|
|
The `slow-consumer` example shows you how to detect slow consumers and configure a slow consumer policy in Apache ActiveMQ Artemis's
|
|
|
|
== Spring Integration
|
|
|
|
This example shows how to use embedded JMS using Apache ActiveMQ Artemis's Spring integration.
|
|
|
|
== SSL Transport
|
|
|
|
The `ssl-enabled` shows you how to configure SSL with Apache ActiveMQ Artemis to send and receive message.
|
|
|
|
== Static Message Selector
|
|
|
|
The `static-selector` example shows you how to configure an Apache ActiveMQ Artemis core queue with static message selectors (filters).
|
|
|
|
== Static Message Selector Using JMS
|
|
|
|
The `static-selector-jms` example shows you how to configure an Apache ActiveMQ Artemis queue with static message selectors (filters) using JMS.
|
|
|
|
== Stomp
|
|
|
|
The `stomp` example shows you how to configure an Apache ActiveMQ Artemis server to send and receive Stomp messages.
|
|
|
|
== Stomp1.1
|
|
|
|
The `stomp` example shows you how to configure an Apache ActiveMQ Artemis server to send and receive Stomp messages via a Stomp 1.1 connection.
|
|
|
|
== Stomp1.2
|
|
|
|
The `stomp` example shows you how to configure an Apache ActiveMQ Artemis server to send and receive Stomp messages via a Stomp 1.2 connection.
|
|
|
|
== Stomp Over Web Sockets
|
|
|
|
The `stomp-websockets` example shows you how to configure an Apache ActiveMQ Artemis server to send and receive Stomp messages directly from Web browsers (provided they support Web Sockets).
|
|
|
|
== Symmetric Cluster
|
|
|
|
The `symmetric-cluster` example demonstrates a symmetric cluster set-up with Apache ActiveMQ Artemis.
|
|
|
|
Apache ActiveMQ Artemis has extremely flexible clustering which allows you to set-up servers in many different topologies.
|
|
The most common topology that you'll perhaps be familiar with if you are used to application server clustering is a symmetric cluster.
|
|
|
|
With a symmetric cluster, the cluster is homogeneous, i.e. each node is configured the same as every other node, and every node is connected to every other node in the cluster.
|
|
|
|
== Temporary Queue
|
|
|
|
A simple example demonstrating how to use a JMS temporary queue.
|
|
|
|
== Topic
|
|
|
|
A simple example demonstrating a JMS topic.
|
|
|
|
== Topic Hierarchy
|
|
|
|
Apache ActiveMQ Artemis supports topic hierarchies.
|
|
With a topic hierarchy you can register a subscriber with a wild-card and that subscriber will receive any messages sent to an address that matches the wild card.
|
|
|
|
== Topic Selector 1
|
|
|
|
The `topic-selector-example1` example shows you how to send message to a JMS Topic, and subscribe them using selectors with Apache ActiveMQ Artemis.
|
|
|
|
== Topic Selector 2
|
|
|
|
The `topic-selector-example2` example shows you how to selectively consume messages using message selectors with topic consumers.
|
|
|
|
== Transaction Failover
|
|
|
|
The `transaction-failover` example demonstrates two servers coupled as a live-backup pair for high availability (HA), and a client using a transacted JMS session failing over from primary to backup when the primary server is crashed.
|
|
|
|
Apache ActiveMQ Artemis implements failover of client connections between primary and backup servers.
|
|
This is implemented by the sharing of a journal between the servers.
|
|
When a primary node crashes, the client connections can carry and continue to send and consume messages.
|
|
When transacted sessions are used, once and only once message delivery is guaranteed.
|
|
|
|
== Failover Without Transactions
|
|
|
|
The `stop-server-failover` example demonstrates failover of the JMS connection from one node to another when the primary server crashes using a JMS non-transacted session.
|
|
|
|
== Transactional Session
|
|
|
|
The `transactional` example shows you how to use a transactional Session with Apache ActiveMQ Artemis.
|
|
|
|
== XA Heuristic
|
|
|
|
The `xa-heuristic` example shows you how to make an XA heuristic decision through Apache ActiveMQ Artemis Management Interface.
|
|
A heuristic decision is a unilateral decision to commit or rollback an XA transaction branch after it has been prepared.
|
|
|
|
== XA Receive
|
|
|
|
The `xa-receive` example shows you how message receiving behaves in an XA transaction in Apache ActiveMQ Artemis.
|
|
|
|
== XA Send
|
|
|
|
The `xa-send` example shows you how message sending behaves in an XA transaction in Apache ActiveMQ Artemis.
|