Skip to content

v0.14.0

Compare
Choose a tag to compare
@alexander-fenster alexander-fenster released this 08 Dec 21:23
· 1105 commits to main since this release

@google-cloud/pubsub 0.14.0 Beta Release

@google-cloud/pubsub is now a Beta API. Libraries defined at the Beta quality level are expected to be mostly stable, while we work towards their release can
didate. We will address issues and requests with a higher priority.

⚠️ Breaking Changes

PubSub received a small redesign!

PR: #2380
API Documentation

Publishing Messages

When publishing messages we no longer allow data to come in the form of Strings or Objects, instead you must pass in a Buffer object. Attributes can now be passed in as a second optional parameter. Messages are batched together, so calling publish() multiple times will not result in multiple requests.

Before

var messages = [
  'foo',
  'bar'
];

topic.publish(message, function(err, messageIds, apiResponse) {});

After

var publisher = topic.publisher();
var callback = function(err, messageId, apiResponse) {};

var message1 = new Buffer('foo');

publisher.publish(message1, callback);

var message2 = new Buffer('bar');
var attributes = {
  key: 'value'
};

publisher.publish(message2, attributes, callback);

Message Handling

  • message.ack() no longer accepts a callback function, instead errors will be reported via subscription.on('error', function(err) {})
  • message.skip() has been removed in favor of message.nack()

Before

subscription.on('message', function(message) {
  // Ack the message
  message.ack(function(err) {});

  // Skip the message
  message.skip();
});

After

subscription.on('message', function(message) {
  // Ack the message (No longer accepts a callback)
  message.ack();

  // Do not ack the message, allowing more messages to come in
  message.nack();
});

subscription.pull() removed.

Please open an issue with any feedback, questions, or issues. We're happy to help during the transition.