You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by elk <ac...@e-lehmann.de> on 2019/03/17 13:14:19 UTC

Messaging between activemq-cpp and websocket

Hello,

I am new to activemq and activemq-cpp.
My goal is to setup queues for communication between a web browser (over
websocket/STOMP) and a C++ program. Since there is some additional business
logic, I've setup a springboot application with embedded ActiveMQ server and
configured the Websocker STOMP support to relay/listen to the embedded
server. The relevant spring configuration code on the java side looks like
(1) and (2) below.

On the C++ side I cloned the repo
https://gitbox.apache.org/repos/asf/activemq-cpp.git and compiled it on
macOS.
Then I modified the example code in src/examples/Main.cpp to connect the
HelloWorldConsumer and HelloWorldProducer to two different queues.The
relevant places in the main() function look like (3) below, the
modifications in the classes are not shown, but are simply a new member in
each and adapted session->createQueue() calls in run(). The queue to listen
on is /myQueue/ below and the queue to put messages in is /yourQueue/ below. 

And there is some Test code in Java that creates a websocket client,
connects it to the springboot websocket port, registers a listener to the
"/queue/browser" and sends a message to "/queue/plugin". This is shown in
(4) below.

Now here is the problem: The reception of messages from the C++ side to the
"browser" (my websocket listener) works fine, the textmessage is transmitted
and can correctly be parsed and displayed. The message from the "browser" to
the C++ side is transmitted and arrives there, BUT is corrupted (i.e. it is
NULL). Here is the output that I get from the example:



/Message #1 Received/ is the one from the "browser" (my test code), and the
"NOT A TEXTMESSAGE" string is displayed because it is NULL (a NULL check in
the HelloWorldConsumer::onMessage() method). The text message is apparently
not correctly parsed on the C++ side.

Is there something missing some further configuration to be done in my code?
Or is it a bug/missing feature? Can I do something to make it work anyway ?

Thanks in advance

 

(1) Jms configuration


(2) Websocket configuration


(3) Relevant places in edited src/examples/Main.cpp of the activemq-cpp code


(4) Java Test code to put a message in the "plugin" queue that should be
consumed on the C++ side.





--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Messaging between activemq-cpp and websocket

Posted by elk <ac...@e-lehmann.de>.
Well, the solution is quite simple: the messages are not transmitted as
/TextMessage/ objects in the sense of activemq-cpp, they are
/ByteMessage/'s.

Casting the message to a ByteMessage, read the bytes and creating a string
from it solved it. Unfortunately neither the readString() nor the readUTF()
method are working for some reason... but anyway, as long as I get the bytes
I am fine.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html