PHP code example of zsd / activemq-sdk-php

1. Go to this page and download the library: Download zsd/activemq-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zsd / activemq-sdk-php example snippets



$queue = $qbus->getQueue($queueName);


$msgId = $queue->sendMessage($message, $delaySeconds);
$msgId = $queue->sendBatchMessage($messages, $delaySeconds);


$msg = $queue->receiveMessage($pollingWaitSeconds);
// 获取消息体
if (!is_null($msg)) {
    $string = $msg->getBody();
}

$msgList = $queue->batchReceiveMessage($messageCount, $pollingWaitSeconds);

// 获取消息体
foreach($msgList as $msg) {
    $string = $msg->getBody();
}


$queue->deleteMessage($message);
$queue->deleteBatchMessage($messages);
 

$topic = $qbus->getTopic($topicName);



$topic->publishMessage($message);
$topic->publishBatchMessage($messages, $tagList, $routingKey, $delaySeconds);


composer 


$qbus = new Mq($endPoint, $userName, $password, $timeoutSeconds, $port);