5 Replies Latest reply on Jan 15, 2009 4:53 PM by peterj

    How to Store a Text File in JMS Queue : setobject

    waheed

      i want to set a file through object in a queue and then read this file from JMS Queue
      Any one tell me about this process

        • 1. Re: How to Store a Text File in JMS Queue : setobject
          peterj

          One possibility: Read the file contents into a string and send the string as the message body.

          • 2. Re: How to Store a Text File in JMS Queue : setobject
            waheed

             

            "PeterJ" wrote:
            One possibility: Read the file contents into a string and send the string as the message body.


            Thnks
            I do this

            But now i want to write Message in a text file
            how it is possible???

            • 3. Re: How to Store a Text File in JMS Queue : setobject
              waheed

               

              "waheed" wrote:
              "PeterJ" wrote:
              One possibility: Read the file contents into a string and send the string as the message body.


              Thnks
              I do this

              But now i want to write Message in a text file
              how it is possible???


              Imean read the message from queue and then write in text file????? how's it possible

              • 4. Re: How to Store a Text File in JMS Queue : setobject
                peterj

                Are you saying that you want to send the java.io.File object in the message so that the receiver can read the file? If so, that is not possible. Nor is it possible to send a java.io.Stream/Writer/whatever. These objects, besides probably not being serializable, do not contain the file contents anyway. And I assume that you are interested in getting the file contents to the receiver. In which case the only option is to read the file contents and send those in the message.

                Another option - if both the sender and receiver has visibility to the file, you could just send the full path name. This would work, for instance, in a Windows environment if you used a UNC name (example: \\myhost\sharename\path\to\the\file.txt).

                • 5. Re: How to Store a Text File in JMS Queue : setobject
                  peterj

                  Or are you saying that you want the message receiver to write the message contents to a file? If so, then that is a general question about writing text to a file in Java and has nothing to do with messaging. Perhaps use java.io.FileWriter.