ActiveMQ / PHP Stomp use TextMessage instead of BytesMessage

artemis stomp
apache activemq protocols
activemq xmpp
activemq message format
clojure activemq
rails activemq
activemq supported languages
activemq ios client

when I send a message to ActiveMQ using PHP-Stomp the message is sent as BytesMessage. However I would like to send an TextMessage.

According to the STOMP documentation this can be achieved by not sending an content-length header:

... The protocol does however support a content-length header. To provide more robust interaction between Stomp and JMS clients, ActiveMQ keys off of the inclusion of this header to determine what message type to create when sending from Stomp to JMS. The logic is simple:

Inclusion of content-length header => Resulting Message

yes => BytesMessage

no => TextMessage

This same logic can be followed when going from JMS to Stomp, as well. A Stomp client could be written to key off of the inclusion of the content-length header to determine what type of message structure to provide to the user.

In my test PHP script I have not defined the content-length header and it seems to be automaticly added. I also tried passing content-length as 0, false or null. In all of these cases it produces a BytesMessage.

So my question is, how do I produce a Textmessage instead of BytesMessage.

My code looks like the following:

<?php

$stomp = new Stomp('tcp://localhost:61613');
$stomp->send('/topic/test.central_message_topic', 'testmessage', [
    "persistent" => "true",
]);

it's been a long time but this worked for me :

try {  
$stomp->send("your_queue", "your_message", array("amq-msg-type" => "text"));
} catch (StompException $e) {  
die('send failed: ' . $e->getMessage());
}

This makes it easy to write a client in pure Ruby, Perl, Python or PHP for Stomp uses a text based wire format that can be configured with the following options. have knowledge of JMS messages such as TextMessage 's or BytesMessage 's. messages in the separate file instead of polluting the standard broker's log. As such, it does not have knowledge of JMS messages such as TextMessage’s or BytesMessage’s. The protocol does however support a content-length header. To provide more robust interaction between STOMP and JMS clients, ActiveMQ keys off of the inclusion of this header to determine what message type to create when sending from Stomp to JMS.

I have found the answer.

TL;DR: It is not possible.

With the PECL-Stomp it is not possible to not send the content-length header, since it is automaticly created when the request is sent. If you pass the reuqest will contain two content-length headers.

For reference the sourcecode.

protocol support content-length header. provide more robust interaction between stomp , jms clients, activemq keys off of inclusion of header  The STOMP protocol (version 1.1 or greater) defines the concept of heart beatsas a method by which a client and broker can determine the health of the underlying TCP connection between them. ActiveMQ supports STOMP heart beating provided the client is using version 1.1 (or greater) of the protocol.

Add transformation header, using this with activemq:

$stomp->send('/queue/pizzamonsters', json_encode($frame), [
    'transformation' => 'TEXT'
]);

You need to set the content-length header on the STOMP message you send in order for it to be translated into a JMS BytesMessage. When I send a JMS text message to an ActiveMQ topic using the activemq-all jar, is a Since you are testing Point-to-Point, you will need a JMS server that uses queues instead of topics. TextMessage vs ByteMessage vs StreamMessage. Hi, Let's say I'm sending data in the form of xml. The data being sent is big but certainly not large enough to warrant the use of BlobMessages.

<?php
$stomp = new Stomp('tcp://localhost:61613');
$stomp->send('/topic/test.central_message_topic', 'testmessage', ["content-type" =>"text/plain"]);

Android is a trademark of Google Inc. Use of this trademark is subject to Google computers if the IP address of the message broker is used instead of localhost. I'm try to send a TextMessage from a ruby producer to Java consumer. The message is being seen as a BytesMessage on the Java side. I've tried setting the type header to TextMessage, javax.jms.TextMessage and org.apache.activemq.commands.ActiveMQTextMessage.

Simple Text Orientated Messaging Protocol(STOMP)—allows developers to use a wide variety of client APIs to connect to a broker. public class ActiveMQBytesMessage extends ActiveMQMessage implements javax.jms.BytesMessage. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes. It inherits from the Message interface and adds a bytes message body. The receiver of the message supplies the interpretation of the bytes.

ActiveMQ / PHP Stomp use TextMessage instead of BytesMessage. when I send a message to ActiveMQ using PHP-Stomp the message is sent as  ActiveMQ-CPP in Action. In the example below we create two classes HolloWorldConsumer and HelloWorldProducer each of which runs in its own thread. The Producer sends TextMessage objects via a MessageProducer instance to the ActiveMQ broker. The Consumer receives messages asynchronously from the broker on the same Topic or Queue as the Producer looking for a set number of TextMessages to arrive.

using Java Messaging Service (JMS) API.2,3 Applications that have been an open-source tool to engage and assess ActiveMQ- based JMS BytesMessage: The ByteMessage type contains an array of WebSockets, and Stomp as shown in the list below. □. AMQP. □ the Internet with 'ActiveMQ' string in response. I'm working on fixing the way the STOMP transport determines Text and Bytes messages for issue AMQ-739. Previously we keyed off of the content-length header - if it was there, it's a bytes message, and otherwise it's a text message.