我目前已經設置了拿東西從ActiveMQ的話題,通過它通過的.xsl改造它,然後把它傳遞到另一個ActiveMQ的話題駱駝的路線。我現在唯一的問題是,我不確定如何真正開始將xml文件發佈到隊列中,以便首先完成整個過程。發送XML文件的ActiveMQ
我想到在短短一個字符串發送整個事情,但我不知道是否會得到拾取的XSL文件轉換的。如果任何人有任何提示或方法發送xml文件到activemq隊列或主題,您的幫助將不勝感激!
謝謝!
我目前已經設置了拿東西從ActiveMQ的話題,通過它通過的.xsl改造它,然後把它傳遞到另一個ActiveMQ的話題駱駝的路線。我現在唯一的問題是,我不確定如何真正開始將xml文件發佈到隊列中,以便首先完成整個過程。發送XML文件的ActiveMQ
我想到在短短一個字符串發送整個事情,但我不知道是否會得到拾取的XSL文件轉換的。如果任何人有任何提示或方法發送xml文件到activemq隊列或主題,您的幫助將不勝感激!
謝謝!
1) 的ActiveMQ自帶的Web控制檯,您可以將消息發送到隊列或主題。 這個控制檯是可用默認的
http://localhost:8161/admin
有一個在ActiveMQ的分佈,讓您的更多細節的Web控制檯自述文件。
2) 您也可以從JConsole中(如JMX)發送消息。
3) 和替代是使用駱駝的路線,從文件目錄消耗和發送的話題。然後,您可以將文件放在目錄中,讓駱駝拾取併發送文件。
<route>
<from uri="file:somedir/inbox"/>
<to uri="activemq:topic:someTopicName"/>
</route>
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
請不要隨便傾倒一些代碼。解釋你的代碼如何實際解決問題中的問題。 – ekad 2015-07-23 13:03:39
@ekad現在回答說明 – 2015-07-24 06:27:58