4 Replies Latest reply on Aug 16, 2008 1:32 PM by Vishal

    multiple messages

    Vishal Novice

      i have a doubt this is probably my missunderstanding but i want to confirm

      following is the code which is suppose to place n messages on ESB
      i want the listener to get invoked n times but it gets invoked very oddly
      this loop currently goes three times but all three messages appear in only one message body when recvd by listener what shud i do to change it to three different messages , please help

      for(Request thisreq: req){
      System.out.println("New Message");
      //System.out.println(thisreq.print_Messages());
      Message esbMessage = MessageFactory.getInstance().getMessage();
      esbMessage.getBody().add(thisreq.print_Messages());
      new ServiceInvoker("TSService","TsListener").deliverAsync(esbMessage);

      //sjm.sendAMessage(thisreq.print_Messages());
      }

        • 1. Re: multiple messages
          Daniel Bevenius Master

          Can you try modifying the helloworld quickstart and update its SendEsbMessage.java and add the following to the main method:

           for ( int i = 0 ; i < 3 ; i++ )
           {
           Message esbMessage = MessageFactory.getInstance().getMessage();
          
           esbMessage.getBody().add("Test body content");
           new ServiceInvoker(args[0], args[1]).deliverAsync(esbMessage);
           }
          
          

          Then run the quickstart with 'ant sendesb'. This will send three different messages to the ESB. They will all have the same message body contents, "Test body content", but that is expected.

          I'm not sure that I fully understand your problem but please try this and let me know if you still have an issue with this.

          Regards,

          /Daniel

          • 2. Re: multiple messages
            Vishal Novice

            thanks Daniel

            I tested the code and worked but is ther any problem if message contains some XML ? any special precautions i have to take or it will work same like a simple string ?

            • 3. Re: multiple messages
              Daniel Bevenius Master

               

              any special precautions i have to take or it will work same like a simple string ?

              No, xml will work fine as the message body payload.



              • 4. Re: multiple messages
                Vishal Novice

                yes thanks daniel !