Supporting Enqueue

Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you’d like to join them, please consider:

STOMP transport


$ composer require enqueue/stomp

Create context

use Enqueue\Stomp\StompConnectionFactory;

// connects to localhost
$factory = new StompConnectionFactory();

// same as above
$factory = new StompConnectionFactory('stomp:');

// same as above
$factory = new StompConnectionFactory([]);

// connect via stomp to RabbitMQ (default) - the topic names are prefixed with /exchange
$factory = new StompConnectionFactory('stomp+rabbitmq:');

// connect via stomp to ActiveMQ - the topic names are prefixed with /topic
$factory = new StompConnectionFactory('stomp+activemq:');

// connect to stomp broker at port 1000 using
$factory = new StompConnectionFactory([
    'host' => '',
    'port' => 1000,
    'login' => 'theLogin',

// same as above but given as DSN string
$factory = new StompConnectionFactory('stomp://');

$context = $factory->createContext();

// if you have enqueue/enqueue library installed you can use a factory to build context from DSN
$context = (new \Enqueue\ConnectionFactoryFactory())->create('stomp:')->createContext();

Send message to topic

/** @var \Enqueue\Stomp\StompContext $context */

$message = $context->createMessage('Hello world!');

$fooTopic = $context->createTopic('foo');

$context->createProducer()->send($fooTopic, $message);

Send message to queue

/** @var \Enqueue\Stomp\StompContext $context */

$message = $context->createMessage('Hello world!');

$fooQueue = $context->createQueue('foo');

$context->createProducer()->send($fooQueue, $message);

Consume message:

/** @var \Enqueue\Stomp\StompContext $context */

$fooQueue = $context->createQueue('foo');

$consumer = $context->createConsumer($fooQueue);

$message = $consumer->receive();

// process a message

// $consumer->reject($message);

back to index