Registry / messaging / message-hub-rest

message-hub-rest

JSON →
library2.0.0jsnpmunverified

Node.js client for IBM Message Hub REST API (version 2.0.0). This version removed consume and produce APIs; users should switch to node-rdkafka for Kafka-level messaging. Legacy release, no longer actively developed. Non-enterprise Message Hub instances only.

npm install message-hub-rest
INSTALL
IMPORT
SIG · MESSAGE-HUB-REST
M
message-hub-rest
messagingjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MessageHub
var MessageHub = require('message-hub-rest');
import MessageHub from 'message-hub-rest';
Only CommonJS supported; no ESM exports.
MessageHub instance
var mh = new MessageHub(services);
var mh = MessageHub(services);
Must use new keyword; constructor throws on invalid services.
topics.get
mh.topics.get()
mh.topics.get
Returns a Promise, not a synchronous value.

Creates a topic, lists all topics, then deletes the created topic using MessageHub REST API.

var MessageHub = require('message-hub-rest'); var services = process.env.VCAP_SERVICES || '{}'; var instance = new MessageHub(services); var topicName = 'test-topic-' + Date.now(); instance.topics.create(topicName) .then(function(response) { console.log('Topic created:', topicName); return instance.topics.get(); }) .then(function(topics) { console.log('Topics:', topics); return instance.topics.delete(topicName); }) .then(function() { console.log('Topic deleted'); }) .catch(function(err) { console.error('Error:', err.message); });
Debug
Known issues
breakingVersion 2.0.0 removes consume and produce APIs. Existing code using these will break.
fix
Use node-rdkafka or another Kafka client for producing/consuming messages.
affects: >=2.0.0
deprecatedThe Message Hub REST API is deprecated; use the Kafka API instead.
fix
Migrate to node-rdkafka and Kafka protocol.
affects: >=1.0.0
gotchaTopic creation incurs a fee; it's not a free operation.
fix
Check Bluemix documentation for pricing before creating topics.
affects: >=0.1.0
gotchaConstructor throws if VCAP_SERVICES is invalid or missing; no error handling is provided by default.
fix
Wrap constructor in try-catch or validate services input.
affects: >=0.1.0
gotchaThe API only works with non-enterprise Message Hub instances; enterprise instances require node-rdkafka.
fix
Ensure you have a non-enterprise Message Hub service.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: MessageHub is not a constructor
Missing 'new' keyword when instantiating.
fix
Use 'new MessageHub(services)' instead of 'MessageHub(services)'.
Error: Invalid VCAP_SERVICES
VCAP_SERVICES environment variable missing or malformed.
fix
Provide valid VCAP_SERVICES JSON string via environment variable.
TypeError: instance.topics.create is not a function
Using version 2.0.0+ where create/delete/get are the only methods; older produce/consume are removed.
fix
Use node-rdkafka for produce/consume; only use message-hub-rest for topic management.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
message-hub-rest — npm install message-hub-rest · libregistry