在我的应用程序中,我使用 JAXB 将对象转换为 XML。我需要将此 XML 文件传输到 ActiveMQ 队列。以前我以这样的字符串形式将消息发送到队列:
public class Main {
private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
private static String subject = "TestQueue";
public static void main(String[] args) throws JMSException {
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(subject);
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage("secondMessage ");
producer.send(message);
connection.close();
}
}
但现在我需要传输 XML 文件。我怎样才能做到这一点?
交互式爱情
相关分类