locked
Reading message property using NodeJs RRS feed

  • Question

  • Hi,

    I am working on creating server using node js to receive all the events sent from different devices (clients). I have to add properties to azure iot hub messages to trigger different tasks in server using node js.

    I can add property to a message in node js client, like 

      var message = new Message(data);
      message.properties.add('myprop','myvalue');

    and also can read this is in client using console.log(message.properties["myprop"]);. 

    But I am unable to read this is in server using event hub endpoint receiver using  amqp client var client = new AMQPClient(Policy.EventHub);. I can read the body of message but properties are always showing as null.

    I have followed this url https://azure.microsoft.com/en-in/documentation/articles/iot-hub-node-node-getstarted/ to create server to read device to cloud messages and I am trying to read property in messageHandler 

    var messageHandler = function (partitionId, message) {
      console.log('Received(' + partitionId + '): ', message.body);

    console.log(message.properties["myprop"]);.  --Property read error

    console.log(message.properties.getItem(0));.  --Property read error

    };

    Could you please suggest to read property values using nodejs ?

    Regards

    Bhuwan

    Tuesday, May 10, 2016 9:30 AM