javascript - Send protobuf(binary) data using rabbitmq stomp -
i have create 1 example rabbitmq stomp using protobuf.js on client side. protobuf example link: https://github.com/dcodeio/protobuf.js
send message file content:-
var game = builder.build("game"); var car = game.cars.car; var car = new car("rusty", "mayur"); var buffer = car.encode(); var mq_username = "guest", mq_password = "guest", mq_vhost = "/", mq_url = 'http://192.168.0.14:15674/stomp', mq_queue1 = '/queue/a3'; var client = stomp.client(mq_url); function on_connect() { client.send(mq_queue1, { priority: 9}, buffer); } window.onload = function () { client.connect( mq_username, mq_password, on_connect, on_connect_error, mq_vhost ); }
receive file content:-
var game = builder.build("game"); var car = game.cars.car; var car = new car("rusty", "mayur"); var buffer = car.encode(); var mq_username = "guest", mq_password = "guest", mq_vhost = "/", mq_url = 'http://192.168.0.14:15674/stomp', mq_queue1 = '/queue/a3'; var client = stomp.client(mq_url); function on_connect() { un = client.subscribe(mq_queue1, on_message); } function on_message(m) { console.log('message received'); console.log(m); var buffer = m.body; alert(buffer); var cardec =car.decode(buffer); alert(cardec.model); } window.onload = function () { client.connect( mq_username, mq_password, on_connect, on_connect_error, mq_vhost ); }
i can not decode data send stomp(protobuf binary data). please guide me set "content-length" stomp header if problem solved through "content-length".
please me. no 1 knows this?
i know i'm answering after 2 years ! thought should share :)
i working on project using rabbitmq stomp send protobuf encoded data.
i faced same problem: send not decode @ receiving end.
i got work using encoding:
change:
var buffer = car.encode();
to:
var buffer = car.encode64();
change:
var cardec =car.decode64(buffer);
to:
var cardec =car.decode64(buffer);
this solved problem, hope solves yours.