gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:55 24 4
gpt4 key购买 nike

我有一个启动嵌入式 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com