ActiveMQ的Broker


  是什么


 不同config配置文件来模拟不同的实例

[root@yangdong conf]# cp activemq.xml activemq1.xml 
[root@yangdong conf]# activemq start xbean:file:/opt/apache-activemq1-5.15.12/conf/activemq.xml 

区别在于redis的配置文件可以放在任何目录,activemq的配置文件只能在原目录


  嵌入式Broker


    POM.XML

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-all -->
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>5.15.11</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.10.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.xbean/xbean-spring -->
    <dependency>
        <groupId>org.apache.xbean</groupId>
        <artifactId>xbean-spring</artifactId>
        <version>4.15</version>
    </dependency>     <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.10</version>
    </dependency>
</dependencies>
 


    Embedoker

import org.apache.activemq.broker.BrokerService;

public class EmbedBroker {

    public static void main(String[] args) throws Exception {
        //ActiveMQ也支持在vm中通信基于嵌入的broker
        BrokerService brokerService = new BrokerService();
        brokerService.setPopulateJMSXUserID(true);
        brokerService.addConnector("tcp://127.0.0.1:61616");
        brokerService.start();
    }
}
 


    队列验证

和Linux上的ActiveMQ是一样的,Broker相当于一个Mini版本的ActiveMQ
 

ActiveMQ Broker 配置文件的位置取决于你是如何部署 ActiveMQ Broker 的。以下是一些常见的部署方式以及对应的配置文件位置: 1. 在本地开发环境中,ActiveMQ Broker 可能作为一个嵌入式组件来使用,此时你可以在你的代码中通过配置文件的路径来加载配置文件。例如: ```java BrokerService broker = new BrokerService(); broker.setBrokerName("myBroker"); broker.addConnector("tcp://localhost:61616"); broker.setPersistent(false); broker.setUseJmx(true); broker.setSchedulerSupport(true); broker.setAdvisorySupport(true); broker.setPlugins(new BrokerPlugin[] {new MyPlugin()}); broker.setDestinations(new ActiveMQDestination[] {new ActiveMQQueue("myQueue")}); broker.start(); ``` 在上述例子中,你可以通过调用 `broker.setPlugins()` 方法来加载插件,通过调用 `broker.setDestinations()` 方法来配置 ActiveMQ Broker 中的队列和主题。 2. 如果你是以独立进程方式运行 ActiveMQ Broker,那么配置文件通常位于 ActiveMQ 安装目录下的 `conf/activemq.xml` 文件中。你可以编辑该文件来配置 ActiveMQ Broker 的行为。例如: ```xml <broker xmlns="http://activemq.apache.org/schema/core" brokerName="myBroker" dataDirectory="${activemq.data}"> <plugins> <bean id="myPlugin" class="com.example.MyPlugin"/> </plugins> <destinations> <queue physicalName="myQueue"/> </destinations> <transportConnectors> <transportConnector name="openwire" uri="tcp://localhost:61616"/> </transportConnectors> </broker> ``` 在上述例子中,你可以通过在 `<plugins>` 元素中添加插件来加载插件,通过在 `<destinations>` 元素中配置 ActiveMQ Broker 中的队列和主题。 希望这些信息可以帮助你找到 ActiveMQ Broker 配置文件的位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值