问题
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
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
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
The method createBlobMessage(File) is undefined for the type Session
Here is the method i am using:
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.
Regards,
Arun
回答1:
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.
来源:https://stackoverflow.com/questions/17550112/sending-files-using-active-mq-with-blobmessage