java - 无法从外部连接到 Jetty 中嵌入的 ActiveMQ 代理

标签 java activemq

我有一个启动嵌入式 ActiveMQ 代理的 Jetty。我尝试使用 JMSToolBox 连接到它,但出现以下异常:

Transport Connection to: tcp://127.0.0.1:44523 failed: java.io.IOException: Unknown data type: 97

我的代码如下:

    File dataFileDir = new File("target/amq-in-action/kahadb");
    KahaDBStore kaha = new KahaDBStore();
    kaha.setDirectory(dataFileDir);
    kaha.setJournalMaxFileLength(1024 * 1204 * 100);
    kaha.setIndexWriteBatchSize(100);
    kaha.setEnableIndexWriteAsync(false);

    List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
    users.add(new AuthenticationUser(USER_NAME, PWD, "users,users_write"));
    SimpleAuthenticationPlugin simpleAuthenticationPlugin = new SimpleAuthenticationPlugin(users);
    simpleAuthenticationPlugin.setAnonymousAccessAllowed(false);

    List<DestinationMapEntry> authorizationEntries = new ArrayList<>();
    // giving permission to read the queue for users groups 
    AuthorizationEntry authorizationEntry = new AuthorizationEntry();
    authorizationEntry.setRead("users");
    authorizationEntry.setWrite("admins,users_write");
    authorizationEntry.setAdmin("admins");
    authorizationEntry.setQueue("Provisioning");
    authorizationEntries.add(authorizationEntry);
    // "Note that full access rights should generally be given to the ActiveMQ.Advisory destinations because by default an ActiveMQConnection uses destination advisors to get early knowledge of temp destination creation and deletion." -> http://activemq.apache.org/security.html
    authorizationEntry = new AuthorizationEntry();
    authorizationEntry.setRead("guests,users");
    authorizationEntry.setWrite("guests,users");
    authorizationEntry.setAdmin("guests,users");
    authorizationEntry.setTopic("ActiveMQ.Advisory.>");
    authorizationEntries.add(authorizationEntry);       
    AuthorizationMap authorizationMap = new DefaultAuthorizationMap(authorizationEntries);
    AuthorizationPlugin authorizationPlugin = new AuthorizationPlugin(authorizationMap);

    // creating the broker service
    broker = new BrokerService();
    broker.setPersistenceAdapter(kaha);
    broker.setUseJmx(false);
    broker.setPlugins(new BrokerPlugin[]{simpleAuthenticationPlugin, authorizationPlugin});
    broker.addConnector("tcp://localhost:61616");

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
    new Resource(null, "java:/ConnectionFactory", connectionFactory);
    broker.start();

我认为我应该能够从外部工具连接到嵌入式队列。
有什么想法吗?

谢谢,
五、

最佳答案

对于JMSToolBox ,JMX必须处于 Activity 状态,所以请更改 broker.setUseJmx(false);
通过 代理.setUseJmx(true);//这是默认值..

您可能还对 this JMSToolBox issue 感兴趣有一个正在运行的示例

丹尼斯

关于java - 无法从外部连接到 Jetty 中嵌入的 ActiveMQ 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52718034/

相关文章:

java - @BeforeClass 和 @AfterClass 在每次测试之前和之后调用

java - Mule 持久 ActiveMQ 重新交付策略

activemq - JMS 消息优先级不适用于消息

java - spring-roo maven项目不支持特殊字符

java - 由 Apache POI 创建时 excel 文件中的兼容模式

java - 单击时透明 JButton 会变成浅蓝色

java - 如何使用 SolrJ Java 应用程序索引不同类型的文件(pdf、word、html 等)

java - ActiveMQ 浏览器需要很长时间才能执行最后一个 .hasMoreElements()

Openshift v3/Kubernetes 上的 ActiveMQ 集群发现

java - 通过 IP 过滤从外部保护 ActiveMQ