无法将本地文件发送到activeMQ
Unable to send local file to activeMQ
我正在使用 activeMQ,我需要向其写入图像。出于某种原因,我可以在网络上指定一个图像,但如果我尝试使用本地图像,则它不起作用。
这是我的代码
public class AMQmessageSender{
static String ActiveMQ_URL = "tcp://UTMSA603:61616";
static String localPicURL = "path_to_my_local_file";
public static void main(String[] args){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQ_URL);
Connection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();
ActiveMQSession session = (ActiveMQSession) connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(“blobs”);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode (DeliveryMode.PERSISTENT);
File file = new File(localPicURL);
BlobMessage message = session.createBlobMessage(file);
producer.send(message);
session.close();
connection.close();
}
}
这是我不断收到的错误
现在我读到一些关于如何需要 http 或 ftp 服务器来完成这项工作的内容,但在 ActiveMQ's website 上,他们似乎只是在本地文件示例中使用文件位置。我真的需要设置一个 http 或 ftp 服务器来通过 ActiveMQ 发送本地文件吗?
是的,当使用 blob 时,您需要使用带外传输,查看更多详细信息:http://activemq.apache.org/blob-messages.html
然后您需要设置所选择的 ftp、http 等并将依赖项添加到客户端类路径。
但还要记住,消息代理不是用于存储大文件的数据库或文件系统。为此使用其他东西。
我正在使用 activeMQ,我需要向其写入图像。出于某种原因,我可以在网络上指定一个图像,但如果我尝试使用本地图像,则它不起作用。
这是我的代码
public class AMQmessageSender{
static String ActiveMQ_URL = "tcp://UTMSA603:61616";
static String localPicURL = "path_to_my_local_file";
public static void main(String[] args){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQ_URL);
Connection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();
ActiveMQSession session = (ActiveMQSession) connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(“blobs”);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode (DeliveryMode.PERSISTENT);
File file = new File(localPicURL);
BlobMessage message = session.createBlobMessage(file);
producer.send(message);
session.close();
connection.close();
}
}
这是我不断收到的错误
现在我读到一些关于如何需要 http 或 ftp 服务器来完成这项工作的内容,但在 ActiveMQ's website 上,他们似乎只是在本地文件示例中使用文件位置。我真的需要设置一个 http 或 ftp 服务器来通过 ActiveMQ 发送本地文件吗?
是的,当使用 blob 时,您需要使用带外传输,查看更多详细信息:http://activemq.apache.org/blob-messages.html
然后您需要设置所选择的 ftp、http 等并将依赖项添加到客户端类路径。
但还要记住,消息代理不是用于存储大文件的数据库或文件系统。为此使用其他东西。