gpt4 book ai didi

java - Blob 消息的 ActiveMQ 连接 URL

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

我的应用程序有一个远程 ActiveMQ 服务器和嵌入式 ActiveMQ 服务器。当我发送短信时它正在工作。但是,当我尝试发送 Blob 消息时,它会抛出由 java.net.MalformedURLExceptionjava.lang.NumberFormatException 引起的 javax.jms.JMSException

我的经纪商网址<​​/strong>

String broker1 = "tcp://localhost:7005?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:61617";

其中 tcp://localhost:7005 是嵌入式代理,http://localhost:61617 是远程代理。

我的生产者代码

File file=new File("C:/Users/xxx/Downloads/1234.txt");

ActiveMQConnection connection = ActiveMQConnection.makeConnection(broker);
connection.start();
ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = session.createQueue("test");
MessageProducer producer = session.createProducer(destination);

BlobMessage message = session.createBlobMessage(file);
System.out.println("upload started");
producer.send(message);
System.out.println("upload finished");
session.close();
connection.close();

最佳答案

URL 应该像这样 embededbroker?jms.blobTransferPolicy.defaultUploadUrl=externalurl

如果嵌入 URL 失败,则将使用外部 URL。默认情况下,activemq 在此链接中提供文件服务器 http://(activemq server ip):portnumber/fileserver

例如,如果您的 activemq 服务器在 localhost url 上运行,则应为 http://localhost:8161/fileserver/

它支持 HTTP 或 FTP 或 SCP 或其他一些点对点协议(protocol)。

关于java - Blob 消息的 ActiveMQ 连接 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30658736/

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