【问题标题】:Sending Files using Active MQ with BlobMessage使用带有 BlobMessage 的 Active MQ 发送文件
【发布时间】:2013-07-07 04:06:19
【问题描述】:

我的应用程序要求通过 HTTP/FTP 协议将文件从一个应用程序发送到另一个应用程序。我发现以下链接告诉我们可以使用支持 Blob 消息的 Active MQ 来完成同样的操作:

activemq.apache.org/blob-messages.html

我在我的 Windows 机器上配置了 ActiveMq 5.8,在我的 pom.xml 中包含了 ActiveMQ 库所需的依赖项,我可以发送简单的 javax.jms.TextMessage 和 @ 987654323@与org.springframework.jms.core.JmsTemplate

但是当我开始使用以下方法发送 BlobMessage 时,在从 javax.jms.Session 对象创建 BlobMessage 对象时出现编译时错误,上面写着

方法 createBlobMessage(File) 未定义 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);
          }
        }


);
}

请帮助解决这个编译时错误。

问候,

阿伦

【问题讨论】:

    标签: activemq spring-jms jmstemplate


    【解决方案1】:

    BlobMessage 方法不是 JMS 规范方法,因此它们不会出现在 javax.jms.Session 接口中,您需要强制转换为 org.apache.activemq.ActiveMQSession 才能使用 BlobMessage 特定功能。

    【讨论】:

    • 你是对的。通过类型转换,我可以从会话实例创建BlobMessage。你能告诉我如何用一些producer 实例发送这个 blob 消息,因为我无法用 JMSTemplate 发送新创建的博客消息。如果您提供一些示例代码来使用 Spring 本身发送 blob 消息会很好。
    猜你喜欢
    • 2014-05-19
    • 2021-11-16
    • 2012-07-30
    • 2019-10-04
    • 2016-08-14
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 2012-05-27
    相关资源
    最近更新 更多