【发布时间】:2016-11-02 22:20:53
【问题描述】:
我的应用程序有一个远程 ActiveMQ 服务器和嵌入式 ActiveMQ 服务器。当我发送短信时,它正在工作。但是当我尝试发送 Blob 消息时,它会抛出由 java.net.MalformedURLException 和 java.lang.NumberFormatException 引起的 javax.jms.JMSException。
我的经纪人网址
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();
【问题讨论】:
-
我认为你应该使用
jms.blobTransferPolicy.uploadUrl而不是jms.blobTransferPolicy.defaultUploadUrl。请参考:activemq.apache.org/blob-messages.html