0

We are using Java(java Beanshell) in ODI to parse a file. We are reading each line and then constructing the message with 4-5 lines combined and pushing on a JMS queue,

To have a line feed we are adding \n at the end of the line.

But when the message is posted on the queue, it takes \n as string instead of special characteristic.

Code snippet:

while (line != null) {
                                if (line.startsWith("010")){
                                                start = true;
                                                end = false;
                                                jmsString = jmsString + line + newline;
                                }else if (start == true && end == false && "099"){
                                                jmsString = jmsString + line + newline;
                                                jmsMessages.add(jmsString);
                                                end = true;
                                                start = false;
                                                jmsString = "";
                                }else if (start == true && end == false ){
                                                jmsString = jmsString + line + newline;
                                }else{
                                                // do nothing
                                }                                    
                                line = reader.readLine();
                }                            
                
                
                reader.close();
                
                if (jmsMessage != null && jmsMessage != ""){
            //3) Create queue session  
        QueueSession ses=con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);  
         
        //4) Get the Queue object  
        Queue t = (Queue)ic.lookup(JMS_QUEUE); 
         
        //5) Create QueueSender object         
        QueueSender sender=ses.createSender(t);  
        
        //6) Create TextMessage object  
         TextMessage msg=ses.createTextMessage();  
         msg.setText(jmsMessage);
          
        //7) Send message  
        sender.send(msg); 


    
                            
            Output:
            testing  

\n0207145636625896767668042052248950786073950000676680420527052249 CE7 10 \n040714563662589676766804205224895078607395000071456366258967 8507232089 LDC DUAL 202002141815ET

user3235631
  • 79
  • 3
  • 14
  • 1
    please edit the question and show the definitions of all the variables you reference. – OldProgrammer Jul 16 '20 at 01:48
  • Incidentally: [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – dnault Jul 16 '20 at 04:13

0 Answers0