使用Active MQ和BlobMessage发送文件 [英] Sending Files using Active MQ with BlobMessage
问题描述
我的应用程序中要求通过HTTP / FTP协议将文件从一个应用程序发送到另一个。我发现以下链接告诉您,使用Active MQ与Blob消息的支持可以完成相同的操作:
I have an requirement in my application to send files from one application to another over HTTP/FTP protocol. I found following link which tells that the same can be done using Active MQ with supoort of Blob messages:
activemq.apache.org/blob-messages.html
activemq.apache.org/blob-messages.html
我在Windows计算机上配置了 ActiveMq 5.8 ,在 pom中包括了 ActiveMQ lib的必需依赖项.xml
,我能够发送简单的 javax.jms.TextMessage
和 javax.jms.MapMessage
与 org.springframework.jms.core.JmsTemplate
I configured ActiveMq 5.8 on my windows machine, included required dependency for ActiveMQ lib in my pom.xml
and i am able to send the simple javax.jms.TextMessage
and javax.jms.MapMessage
with org.springframework.jms.core.JmsTemplate
但是当我使用以下命令发送BlobMessage时以下方法,从 javax.jms.Session
对象创建 BlobMessage
对象时出现编译时错误
But while i moved to send BlobMessage using following method, a compile time error arises while creating the BlobMessage
object from javax.jms.Session
object which says
未为Session类型定义方法createBlobMessage(File)
The method createBlobMessage(File) is undefined for the type Session
这里是我使用的方法:
public void sendFile(){
jmsTemplate.send(
new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
BlobMessage message = session.createBlobMessage(new File("/foo/bar"));
return jmsTemplate.send(message);
}
}
);
}
请帮助解决此编译时错误。
Please help to resolve this compile time error.
问候
阿伦
推荐答案
BlobMessage方法不是JMS规范方法,因此它们不会出现在javax.jms.Session接口中,您需要强制转换为org.apache.activemq.ActiveMQSession才能使用BlobMessage特定的功能。
The BlobMessage methods are not JMS spec methods so they won't appear in the javax.jms.Session interface, you need to cast to org.apache.activemq.ActiveMQSession in order to use the BlobMessage specific functionality.
这篇关于使用Active MQ和BlobMessage发送文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!