Hello Shree.

This is more of a comment on the system design, but if you're dealing with an all-Java based system (sounds like it since you're using Castor to unmarshall on the client), why not simply send Java objects (i.e. Java->JMS->Java) instead of sending XML (i.e. Java->XML->JMS->XML->Java)? Dealing solely with Java objects, despite serialization, I believe would improve performance since un/marshalling to verbose XML would be eliminated.

I wish that I could find the article, but I read that if dealing with an all-Java based system, it's better to use Java objects. XML is really a common data format for tying together systems built in different languages. Also, using only Java objects should greatly simplify development.

If you must use XML, for one reason or another, please ignore the above.



At 10:30 03/07/01 -0700, you wrote:
Hello...
         Let me put in a nutshell what I have been trying to do. I have
been playing with a JMS application. What I do is retrieve some data
from Sybase, form OBJECTS out of it and then MARSHAL the Object tree
into a XML file. Then, I send this XML data as a TextMessage to a
Message Driven Bean. In the onMessage() method of the MDB, I print out
the message received. Everything is fine till here. Now, to UNMARSHAL
the XML back into the Object hierarchy, I create a Reader using
StringReader(String) and then use UnMarshaller.unmarshal(Class, Reader)
method. This doesn't seem to work. Also, the message is being sent back
to the queue cos it is not being consumed because of some Exception
being thrown during the Unmarshalling process. I have written code to
catch any Exception thrown. Surprisingly, the Exception is not caught
and the Message reappears.
         Has anyone faced a similar problem? Is there something I can do
to get this working? Thanks a bunch to everyone!!!
-Shree Iyer

P.S. Here is a snippet of the code...
This is the piece of code which does the Marshalling and then sends a
Message to JMS.
   // The Object tree is represented by result
    FileWriter writer = new FileWriter("LoanSelectionUpdate.xml");
    Marshaller.marshal(result, writer);
    System.out.println("Created XML document....");
    BufferedReader buf = new BufferedReader(new
FileReader("LoanSelectionUpdate.xml"));
    StringBuffer data = new StringBuffer();
    String line = new String();
    while ((line = buf.readLine()) != null)
    {
         data.append(line);
    }
    msg = qSession.createTextMessage();
    msg.setText(data.toString());
    // Sending the message to a JMS queue...
    qSender.send(msg);

This is the piece of code in the MDB within the onMessage() method
  try
  {
   if (message instanceof TextMessage)
   {
    // The String containing the XML content which is to be parsed
    String xmldoc = ((TextMessage) message).getText();
    log.debug("Incoming XML :******************* ");
   // This prints out the right XML document content...
    log.debug(xmldoc);
    System.out.println("About to unmarshal XML document");
    Reader reader = new StringReader(xmldoc);
    try
    {
            // This line doesn't seem to be working...
           LoanSelectionUpdateDTO loanSelectionUpdateDto =
(LoanSelectionUpdateDTO)
Unmarshaller.unmarshal(LoanSelectionUpdateDTO.class, reader);
    }
  &nbs!
p; // If at all an Exception is thrown, it is not being caught
here...Surprising...!!!
    catch (Exception me)
    {
         me.printStackTrace();
         System.out.println("Exception while unmarshalling... Upper" +
me.getMessage());
    }
   // It doesn't get here...the onMessage() method returns and tries to
consume the message again...probably because an Exception was
thrown...but no clue where!!


Do you Yahoo!?
<http://pa.yahoo.com/*http://rd.yahoo.com/evt=1207/*http://promo.yahoo.com/sbc/>SBC Yahoo! DSL - Now only $29.95 per month!

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev




Reply via email to