Signalman Posted December 18, 2012 Share Posted December 18, 2012 Ok, I am new to this forum, and also new to php, so apologies in advance if I have posted this in the wrong forum, or of it has been answered previously (although I did search prior to posting). The setup I have is running windows xp, using activemq, STOMP and php. I have installed activemq , and started it running, this would appear to be confirmed by the fact that I can see it in Internet explorer. I have downloaded STOMP and as I am unsure how to insert a link to a library in the php code, I have put everything in the one directory (editing the STOMP files where they specify a sub directory). When i run the sample php code, it does not have the desired effect, but generates the following in the IE screen :- connect(); // send a message to the queue $con->send("/queue/test", "test"); echo "Sent message with body 'test'\n"; // subscribe to the queue $con->subscribe("/queue/test"); // receive a message from the queue $msg = $con->readFrame(); // do what you want with the message if ( $msg != null) { echo "Received message with body '$msg->body'\n"; // mark the message as received in the queue $con->ack($msg); } else { echo "Failed to receive a message\n"; } // disconnect $con->disconnect(); ?> I have tried numerous things to get this to work, without success. I am sure it is something simple, once you know. Any assistance would be appreciated. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/272151-php-connect-stomp-activemq/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2012 Share Posted December 18, 2012 What does the opening php tag in the code look like? <? or <?php Have you tested if any php code in a .php file works? Link to comment https://forums.phpfreaks.com/topic/272151-php-connect-stomp-activemq/#findComment-1400166 Share on other sites More sharing options...
Signalman Posted December 18, 2012 Author Share Posted December 18, 2012 The tag is <? As copied from the example. The complete code is below :- <? // include a library require_once("Stomp.php"); // make a connection $con = new Stomp("tcp://localhost:61613"); // connect $con->connect(); // send a message to the queue $con->send("/queue/test", "test"); echo "Sent message with body 'test'\n"; // subscribe to the queue $con->subscribe("/queue/test"); // receive a message from the queue $msg = $con->readFrame(); // do what you want with the message if ( $msg != null) { echo "Received message with body '$msg->body'\n"; // mark the message as received in the queue $con->ack($msg); } else { echo "Failed to receive a message\n"; } // disconnect $con->disconnect(); ?> I have tried a 'hello world' programme and that seems to work ok, however that did have the tag of <?php at the start. From your question, I am guessing that there is a difference ? Link to comment https://forums.phpfreaks.com/topic/272151-php-connect-stomp-activemq/#findComment-1400175 Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2012 Share Posted December 18, 2012 The short <? opening php tag is not always enabled and you won't always be on a server where you can enable it. All code, especially posted, published, tutorials, examples, ... should use the full opening <?php tag. Link to comment https://forums.phpfreaks.com/topic/272151-php-connect-stomp-activemq/#findComment-1400183 Share on other sites More sharing options...
Signalman Posted December 18, 2012 Author Share Posted December 18, 2012 Thanks very much, I have changed the tag to include php and whilst the code is not totally working, it is being processed as I would expect. I can now continue getting the code to run, now it is at least being processed. I guess I have shown that I am very new to Php. Thanks for your assistance with something as basic as this. Link to comment https://forums.phpfreaks.com/topic/272151-php-connect-stomp-activemq/#findComment-1400185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.