我目前有一个camel路由设置为从activemq主题中获取内容,将其传递给.xsl进行转换,然后将其传递给另一个activemq主题。我现在唯一的问题是我不确定如何实际将xml文件发布到队列中,以便开始整个过程。
我想过用一个字符串发送整个东西,但我不确定是否会被xsl文件拾取来转换它。如果有人有任何提示或方法将xml文件发送到activemq队列或主题,我们将非常感谢您的帮助!
谢谢!
答案 0 :(得分:1)
1) ActiveMQ附带一个Web控制台,您可以在其中将消息发送到队列或主题。
默认情况下可以使用此控制台http://localhost:8161/admin
ActiveMQ发行版中有一个WebConsole自述文件,提供了更多详细信息。
2) 您也可以从JConsole发送消息(例如JMX)。
3) 另一种方法是使用Camel路由,它从文件目录中消耗并发送到主题。然后你可以将文件放在目录中,让Camel拾取并发送文件。
<route>
<from uri="file:somedir/inbox"/>
<to uri="activemq:topic:someTopicName"/>
</route>
答案 1 :(得分:0)
Please refer the below code. Here we will receive message simple file creation then writing bytes coming from BytesMessageObject until EOF occurs. BytesMessage bm = (BytesMessage)topicSubscriber.receiveNoWait(); // receive(1000); System.out.println("bm-->"+bm); if(bm !=null){ File file = new File("D:/jms/myfie.txt"); //file created FileOutputStream fos = new FileOutputStream(file);//create fileoutput stream BufferedOutputStream outBuf = new BufferedOutputStream(fos);//create bufferoutputstream int i; while((i=bm.readInt())!=-1)//read unitil EOF means -1 { outBuf.write(i);//write it to the file } System.out.println("outBuf-->"+outBuf); System.out.println(file.isFile()); outBuf.close();//close output buffer fos.close();//close file ouput stream } Here the file is opened then Wrote in BytesMessageObject. Sent Across the Queue Sender code : File f=new File("D:/Import.txt");//get file handle System.out.println("is File "+f.isFile()); BytesMessage bm = topicSession.createBytesMessage();//create bytes message InputStream in= new FileInputStream(f);//create input stream with file handle BufferedInputStream inBuf= new BufferedInputStream(in);//create buffer input stream int i; while((i=inBuf.read())!=-1)//read file until EOF(-1) is reached{ bm.writeInt(i);//write in bytesmessage } System.out.println("after while"); //adding an eof bm.writeInt(-1);//add EOF in bytes message System.out.println("BM = "+bm); topicPublisher.send(bm);///send the bytes message System.out.println("sent successfully"); topicConnection.stop();//stop connection