5 Replies Latest reply on Jul 8, 2011 12:08 AM by Clebert Suconic

    Sending custom objects with HornetQ Core

    Dimitrij Smelanskij Newbie

      Hi,

       

      I have to send a complex object via Hornet queue.

      following examples my code looks like:

       

      Message receiver:

       

      messageConsumer.setMessageHandler(new MessageHandler() {

       

      public void onMessage(ClientMessage message) {

       

      System.out.println("Message size: " + message.getBodyBuffer().capacity());
      byte[] bMessage = new byte[message.getBodySize()];

      message.getBodyBuffer().getBytes(0, bMessage);

      MyMessageType myMessage = (MyMessageType) toObject(bMessage);

       

      }
      });

       

      Message sender:

       

      ClientMessage cMessage = session.createMessage(false);
      MyMessageType myMessage = getMyMessage();

      cMessage.getBodyBuffer().writeBytes(toByteArray(myMessage));
      System.out.println("Message size: " + cMessage.getBodyBuffer().capacity());
      producer.send(cMessage);

       

      The size of BodyBuffer for sending is different from received BodyBuffer.

      1500 send, 849 received.

      Do I something wrong?

      Is there another way to send custom objects using HornetQ Core?