6 Replies Latest reply on Nov 9, 2011 9:12 AM by Sergey Chernov

    PHP Stomp client (Hornetq 2.2.5 Final)

    Sergey Chernov Newbie

      Good day,


      Risently, I've faced the problem with sending messages to HornetQ from my php script.


      I have java code which receives messages:


      1   ClientMessage msg = session.recv(1000);

      2   if (msg != null) {

      3          String property = msg.getString("property");

      4          String body = msg.getBodyBuffer().readString();

      5    }



      And there is PHP code, which send messages:


      1  $stomp = new Stomp("tcp://localhost:61613")

      2  $connection = $stomp->connect("user", "password");

      3  $message = json_encode(array("test" => "It is just test"));

      4  $connection->send($message);


      When message sent by PHP script received by Java client last one get ArrayIndexOutOfBoundException thrown at 4th line. That is a problem.



      I've tried to replace 4th line code with:


      byte[] bytes = byte[msg.getBodyBuffer().readableBytes()];





      and tried this code whith other java client which sends message.

      It turned out that PHP message produces next out put:

      [1, 0, 0, 0, 80, 0, <char code>, 0, <char code>, 0, .... , <leading zero>]

      but java code:

      [0, 0, 0, 40, 0, 40, <char code>, <char code>, ... , <leading zero]


      So I thought that PHP sends UTF-16, but it is not due to tcpdump.


      I've do search over this forum, and have not found any solution or workaround.


      Updated: test eclipse project is attached to reproduce issue. How to run it 1. create user library with all hornetq jars (may use yours) to make java client work 2. check that php is installed 3. run java client first, then 'php ./php_sender' from project's root