
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
message-hub-rest
Advanced tools
Node.js module for connecting to the Kafka REST interface of IBM Message Hub.
IBM Message Hub is a scalable, distributed, high throughput message bus to unite your on-premise and off-premise cloud technologies. You can wire micro-services together using open protocols, connect stream data to analytics to realise powerful insight and feed event data to multiple applications to react in real time.
This Node.js module provides a high-level API by which you can interact with the REST API exposed by the Message Hub service.
Note:
From version 2.0.0
onwards, the consume and produce APIs have been removed as the Message Hub Enterprise offering does not support them. Customers should instead use node-rdkafka for Kafka API-level messaging.
You will need a Node.js 0.12.x runtime environment to use this module. This can be installed from http://nodejs.org/download/, or by using your operating system's package manager.
Installing using npm:
npm install message-hub-rest
npm test
The following example sets up a connection to the Message Hub REST API, creates a topic, consumer and producer, then produces and consumes a few messages before exiting.
var MessageHub = require('message-hub-rest');
var services = process.env.VCAP_SERVICES;
var instance = new MessageHub(services);
var topicName = 'mytopic';
instance.topics.create(topicName)
.then(function(response) {
console.log('Topic created.');
})
.fail(function(error) {
throw new Error(error);
});
Constructs a new Client object, provided with Bluemix VCAP_SERVICES and additional options used to help connect to a particular service.
services
- (Object) VCAP_SERVICES of your Bluemix Message Hub service.opts
- (Object) Optional configuration options used when connecting to the service. Properties include:
Instantiate with the new
keyword. When instantiated correctly, a new MessageHub/Client object will be returned. Throws an error with an accompanying message if the provided services information is incorrect.
Retrieves a list of all topics connected to the provided API key.
Returns a Promise object which will be fulfilled when the request to the service resolves.
Creates a topic of the specified name. Important Note: Creating topics incurs a fee - check the Bluemix documentation for more information.
topic
- (String) (required), the topic name for the service to create.partitions
- (Number) (optional), the number of partitions to use for this topic. Defaults to 1.retentionHours
- (Number) (optional), the number of hours to retain messages on this topic. Minimum is 24 hours, if retentionHours is less than this, it will be set to the minimum.Returns a Promise object which will be fulfilled when the request to the service resolves.
Deletes a topic of the specified name.
topic
- (String) (required), the topic name to delete from the service.Returns a Promise object which will be fulfilled when the request to the service resolves.
FAQs
Node.js module for connecting to the Kafka REST interface of IBM Message Hub.
We found that message-hub-rest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.