Convert Figma logo to code with AI

apache logoactivemq

Mirror of Apache ActiveMQ

2,294
1,446
2,294
51

Top Related Projects

Spring Framework

Open source RabbitMQ: core server and tier 1 (built-in) plugins

28,317

Mirror of Apache Kafka

21,052

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.

14,104

Apache Pulsar - distributed pub-sub messaging system

14,240

Vert.x is a tool-kit for building reactive applications on the JVM

Quick Overview

Apache ActiveMQ is a popular open-source message broker written in Java that supports multiple protocols, including AMQP, MQTT, STOMP, and OpenWire. It provides high availability, scalability, and security features for enterprise messaging applications, making it suitable for both small and large-scale deployments.

Pros

  • Supports multiple messaging protocols, allowing for flexibility in client implementations
  • Offers clustering and high availability features for improved reliability
  • Provides extensive documentation and a large community for support
  • Includes advanced features like message persistence, security, and transaction support

Cons

  • Can be complex to set up and configure for advanced use cases
  • Performance may be lower compared to some newer message brokers
  • Memory usage can be high, especially with large message volumes
  • Learning curve can be steep for newcomers to message-oriented middleware

Code Examples

  1. Sending a message using JMS API:
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("MyQueue");
MessageProducer producer = session.createProducer(destination);

TextMessage message = session.createTextMessage("Hello, ActiveMQ!");
producer.send(message);
  1. Receiving a message using JMS API:
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("MyQueue");
MessageConsumer consumer = session.createConsumer(destination);

connection.start();
TextMessage receivedMessage = (TextMessage) consumer.receive();
System.out.println("Received message: " + receivedMessage.getText());
  1. Using Spring JMS Template to send a message:
@Autowired
private JmsTemplate jmsTemplate;

public void sendMessage(String message) {
    jmsTemplate.send("MyQueue", session -> session.createTextMessage(message));
}

Getting Started

  1. Download and install Apache ActiveMQ from the official website.
  2. Start the ActiveMQ broker:
    ./bin/activemq start
    
  3. Add the ActiveMQ client dependency to your project:
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-client</artifactId>
        <version>5.16.5</version>
    </dependency>
    
  4. Use the code examples provided above to start sending and receiving messages.

Competitor Comparisons

Spring Framework

Pros of Spring Framework

  • More comprehensive ecosystem with extensive support for various application types
  • Larger community and more frequent updates
  • Better integration with modern Java features and other popular frameworks

Cons of Spring Framework

  • Steeper learning curve due to its vast feature set
  • Can be overkill for simple applications
  • Potential for over-engineering and unnecessary complexity

Code Comparison

Spring Framework (Dependency Injection):

@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;
    
    public User findUser(Long id) {
        return userRepository.findById(id);
    }
}

ActiveMQ (Message Producer):

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("myQueue");
MessageProducer producer = session.createProducer(queue);

Spring Framework offers a more declarative approach with annotations, while ActiveMQ requires more explicit setup for messaging. Spring's code is generally more concise and focuses on business logic, whereas ActiveMQ's code deals directly with messaging infrastructure.

Open source RabbitMQ: core server and tier 1 (built-in) plugins

Pros of RabbitMQ

  • Better performance and scalability for high-throughput scenarios
  • More extensive plugin ecosystem and community support
  • Built-in support for multiple protocols (AMQP, MQTT, STOMP)

Cons of RabbitMQ

  • Steeper learning curve due to more complex architecture
  • Higher resource consumption, especially memory usage
  • Less native support for Java-based applications compared to ActiveMQ

Code Comparison

RabbitMQ (Erlang):

basic_publish(Channel, <<"my_exchange">>, <<"routing_key">>, <<"Hello, World!">>),
{#'basic.get_ok'{}, Content} = basic_get(Channel, <<"my_queue">>, no_ack),
io:format("Received: ~p~n", [Content]).

ActiveMQ (Java):

TextMessage message = session.createTextMessage("Hello, World!");
producer.send(message);
TextMessage receivedMessage = (TextMessage) consumer.receive();
System.out.println("Received: " + receivedMessage.getText());

Both repositories provide robust message broker solutions, but RabbitMQ offers better performance and protocol support, while ActiveMQ excels in Java integration and ease of use for simpler scenarios. The code examples demonstrate the different languages and slightly different approaches to publishing and consuming messages in each system.

28,317

Mirror of Apache Kafka

Pros of Kafka

  • Higher throughput and scalability for large-scale data streaming
  • Better support for distributed systems and fault tolerance
  • More flexible partitioning and replication capabilities

Cons of Kafka

  • Steeper learning curve and more complex setup
  • Higher resource consumption, especially for smaller deployments
  • Less mature support for traditional messaging patterns (e.g., request-response)

Code Comparison

Kafka producer example:

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer<String, String> producer = new KafkaProducer<>(props);

ActiveMQ producer example:

ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("MyQueue");
MessageProducer producer = session.createProducer(destination);

Both Kafka and ActiveMQ are popular message brokers, but they have different strengths. Kafka excels in high-throughput, distributed scenarios, while ActiveMQ offers a more traditional messaging approach with broader protocol support. The choice between them depends on specific use cases and requirements.

21,052

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.

Pros of RocketMQ

  • Higher throughput and lower latency, especially for large-scale messaging scenarios
  • Better support for distributed transactions and message tracing
  • More flexible message storage with multiple replicas and fault tolerance

Cons of RocketMQ

  • Steeper learning curve and more complex configuration
  • Less mature ecosystem and fewer third-party integrations compared to ActiveMQ
  • Requires more resources and may be overkill for smaller applications

Code Comparison

ActiveMQ (Java):

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("myQueue");
MessageProducer producer = session.createProducer(destination);

RocketMQ (Java):

DefaultMQProducer producer = new DefaultMQProducer("ProducerGroup");
producer.setNamesrvAddr("localhost:9876");
producer.start();
Message msg = new Message("TopicTest", "TagA", "Hello RocketMQ".getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.send(msg);

Both ActiveMQ and RocketMQ are powerful message queue solutions, but RocketMQ is generally better suited for high-throughput, large-scale scenarios, while ActiveMQ may be more appropriate for simpler use cases or applications with existing ActiveMQ integrations.

14,104

Apache Pulsar - distributed pub-sub messaging system

Pros of Pulsar

  • Better scalability and performance for large-scale distributed messaging
  • Multi-tenancy support with built-in isolation between tenants
  • Unified streaming and queuing model, simplifying architecture

Cons of Pulsar

  • Steeper learning curve due to more complex architecture
  • Requires more resources to run, especially for smaller deployments
  • Less mature ecosystem compared to ActiveMQ

Code Comparison

ActiveMQ (Java):

ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("myQueue");
MessageProducer producer = session.createProducer(destination);

Pulsar (Java):

PulsarClient client = PulsarClient.builder()
    .serviceUrl("pulsar://localhost:6650")
    .build();
Producer<byte[]> producer = client.newProducer()
    .topic("my-topic")
    .create();

Both ActiveMQ and Pulsar provide Java client libraries for producing and consuming messages. Pulsar's API is generally more concise and modern, while ActiveMQ follows a more traditional JMS-style approach. Pulsar's code tends to be more focused on topics, reflecting its unified streaming and queuing model, whereas ActiveMQ separates queues and topics more explicitly.

14,240

Vert.x is a tool-kit for building reactive applications on the JVM

Pros of Vert.x

  • Lightweight and high-performance, designed for reactive applications
  • Polyglot, supporting multiple programming languages
  • Non-blocking, event-driven architecture for better scalability

Cons of Vert.x

  • Steeper learning curve for developers new to reactive programming
  • Smaller ecosystem and community compared to ActiveMQ
  • Less suitable for traditional enterprise messaging scenarios

Code Comparison

Vert.x (Java):

Vertx vertx = Vertx.vertx();
vertx.createHttpServer().requestHandler(req -> {
  req.response().putHeader("content-type", "text/plain").end("Hello World!");
}).listen(8080);

ActiveMQ (Java):

ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("TEST.FOO");
MessageProducer producer = session.createProducer(destination);

Summary

Vert.x is a lightweight, reactive framework suitable for building high-performance, scalable applications, while ActiveMQ is a robust, traditional message broker focused on enterprise messaging scenarios. Vert.x offers more flexibility in terms of programming languages and is better suited for event-driven architectures, whereas ActiveMQ provides a more familiar messaging paradigm for enterprise developers.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Welcome to Apache ActiveMQ

Apache ActiveMQ is a high performance Apache 2.0 licensed Message Broker. ActiveMQ supports several API and protocols:

  • Jakarta Messaging 3.1.0, JMS 2.0 and JMS 1.1.
  • AMQP
  • MQTT
  • HTTP/WS ActiveMQ also provides advanced features like:
  • network of brokers
  • scheduling
  • and much more!

Getting Started

To help you get started, try the following links:

Getting Started

Building

Examples

We welcome contributions of all kinds, for details of how you can help https://activemq.apache.org/contributing.html

Please refer to the website for details of finding the issue tracker, email lists, wiki or IRC channel at https://activemq.apache.org/

Please help us make Apache ActiveMQ better - we appreciate any feedback you may have.

Enjoy!

Licensing

This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See https://www.wassenaar.org/ for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this Apache Software Foundation distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.

The following provides more details on the included cryptographic software:

ActiveMQ supports the use of SSL TCP connections when used with with a JVM supporting the Java Cryptography extensions https://www.oracle.com/java/technologies/javase/javase-tech-security.html. ActiveMQ does not include these libraries itself, but is designed to use them.