2013-02-08 153 views
0

我目前已经设置了拿东西从ActiveMQ的话题,通过它通过的.xsl改造它,然后把它传递到另一个ActiveMQ的话题骆驼的路线。我现在唯一的问题是,我不确定如何真正开始将xml文件发布到队列中,以便首先完成整个过程。发送XML文件的ActiveMQ

我想到在短短一个字符串发送整个事情,但我不知道是否会得到拾取的XSL文件转换的。如果任何人有任何提示或方法发送xml文件到activemq队列或主题,您的帮助将不胜感激!

谢谢!

回答

1

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> 
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 

+0

请不要随便倾倒一些代码。解释你的代码如何实际解决问题中的问题。 – ekad 2015-07-23 13:03:39

+0

@ekad现在回答说明 – 2015-07-24 06:27:58