amqp / rhea

A reactive messaging library based on the AMQP protocol
Apache License 2.0
282 stars 79 forks source link

issue with content_type for Apache ActiveMQ #424

Open jhgil opened 4 months ago

jhgil commented 4 months ago

Hello, I don't know if it's a problem, the body of the messages I send have a binary format, for example:

SpESsESw�Hello, ActiveMQ

i am using Apache activeMQ v5.15.6, node v20.15.1, npm v10.7.0

Screenshot 2024-07-29 at 5 00 27 PM
    connection.once('connection_open', () => {      
      const sender = connection.open_sender('readings');      
      sender.once('sendable', () => {
        let message = "Hello, ActiveMQ";

        sender.send({
          body: message          
        });

        console.log(`Mensaje enviado a mi_cola: ${message}`);

        setTimeout(() => {
          sender.close();
          connection.close();
        }, 500);
      });
    });

how can I force the body of a message to be encoded as plain JSON or text plain data?

grs commented 4 months ago

The message body is being sent as a string. However, as rhea is an AMQP library, the messages as a whole is encoded in the AMQP type system.

I believe ActiveMQ by default treats the entire AMQP message as the body of a JMS BytesMessage. See 'Mapping to JMS' in https://activemq.apache.org/components/classic/documentation/amqp. You may need to configure the broker to choose a different treatment e.g. 'jms'.