Open garrettahines1 opened 4 years ago
Can you paste me the application.properties
.
I'm trying to reproduce but so far I am not able to receive STOMP messages.
amqp-username=admin amqp-password=admin
mp.messaging.incoming.channel-name.connector=smallrye-amqp mp.messaging.incoming.channel-name.address=address-name mp.messaging.incoming.channel-name.durable=true
So, the connector is still connecting to the port 5672
right?
If I send STOM messages on port 61613
, on the destination "/q", I should receive them on the address /q
, or is there anything fancy to do on the artemis side?
Ok, got it to "work" somehow....
At least I receive stuff...
So the issue is that the STOMP message body is passed to AMQP as binary content. It does not include content-type or content-encoding that would give a hint about the type of content.
You can use the following as work-around:
@Incoming("stomp")
public void consume(byte[] payload) throws UnsupportedEncodingException {
String s = new String(payload, "UTF-8");
System.out.println(">> " + s);
}
I am setting 'amq-msg-type': 'text' in the header of the STOMP message, is there something else I should be setting?
it is something "standard", if so, we can check for this property.
I've found others that use it like here. https://stackoverflow.com/questions/31559039/activemq-php-stomp-use-textmessage-instead-of-bytesmessage But don't see anything in the official STOMP documentation, so not sure if its a standard. The byte[] should suffice.
STOMP spec is very minimal, so that does not surprise me, but we can add this heuristic.
If an AMQP message has the amq-msg-type
: text
property set (BTW, which group of property are you using?) we can safely read the body as a String even if it's a binary value.
BTW, there is another proposal on SO proposing to use the content-type, it might be better. WDYT?
content-type works fine.
Ok, so let's go with the content-type
header.
This is actually more important than I thought. Using byte array works fine STOMP->AMQP but we get an error that string cannot be cast to byte array when we do AMQP->AMQP. Ideally we would not care which protocol sends the message.
do you have the stack trace or a reproducer?
I'm getting this same error. Doesn't occur with activeMQ but after upgrading activeMQ to artemis need to change the incoming stream to bytes for some reason for messages coming from stomp.
Describe the bug I am using smallrye-amqp to listen to messages over artemis mq. From a node js service I am sending a text message using the STOMP protocol. Get the following error when receiving the message in my java application. I am trying to receive the message as a String which fails but if I receive it as a byte[] it works.
Here is my method:
To Reproduce Steps to reproduce the behavior:
Environment (please complete the following information):
java -version
: 11.0.2