I have created a topic using node.js and mapped to Message Hub using prototype MessageHub.prototype.topics.create(topic). I want to add an existing Message Hub topic to node.js and consume data from it. Is there any function for this?
Asked
Active
Viewed 85 times
0
-
1Please add the code for what you have done so far. – ralphearle Dec 07 '16 at 14:48
2 Answers
2
@rajeswari the topics.create(topicName)
call simply requests the topic is created in MessageHub and when its Promise returns the json output response of that request is available.
If you want to retrieve messages from an existing topic, you can just skip that step and proceed directly to creating a ConsumerInstance via MessageHub.prototype.consume
and then call MessageHub.ConsumerInstance.prototype.get(topicName)
on the returned ConsumerInstance.

Dominic Evans
- 370
- 1
- 4
2
@rajeswari I guess you're using the node.js module that uses Message Hub REST API.
Feel free to have a look at an example using a native Node.js client for Kafka,
https://github.com/ibm-messaging/message-hub-samples/tree/master/kafka-nodejs-console-sample

Edoardo Comar
- 531
- 2
- 5