Release Pub/Sub 0.27.0
·
24484 commits
to main
since this release
This is a major release that offers new functionality. It adds the ability to asynchronously publish batches of messages when a threshold is met (batch message count, total batch size, batch age). It also adds the ability to receive and acknowledge messages via multiple streams.
A topic can now asynchronously publish messages in batches when a threshold is met (batch count, batch size, batch age), and yields a PublishResult object:
require "google/cloud/pubsub"
pubsub = Google::Cloud::Pubsub.new
topic = pubsub.topic "my-topic"
topic.publish_async "task completed" do |result|
if result.succeeded?
log_publish_success result.data
else
log_publish_failure result.data, result.error
end
end
# time passes...
topic.async_publisher.stop.wait!A Subscriber object streams messages using gRPC's streaming capability, placing received messages in inventory until they are handled by the user:
require "google/cloud/pubsub"
pubsub = Google::Cloud::Pubsub.new
sub = pubsub.subscription "my-topic-sub"
subscriber = sub.listen do |msg|
log_received_message msg
msg.ack!
end
subscriber.start
# time passes...
subscriber.stop.wait!- Publishing Messages Asynchronously
Topic#publish_asyncandAsyncPublisheraddedAsyncPublishercan be stoppedPublishResultobject is yielded fromTopic#publish_async
- Subscriber Streaming Messages
Subscription#listenchanged to return aSubscriberobjectSubscribercan open multiple streams to pull messagesSubscribermust be started to begin streaming messagesSubscribercan be stoppedSubscriber's received messages are leased until acknowledged or rejected
- Other Additions
ReceivedMessage#reject!method added (aliased asnack!andignore!)Message#published_atattribute was added
- Removals
Project#publishmethod has been removedProject#subscribemethod has been removedProject#topicmethod argumentautocreatewas removedSubscription#pullmethod argumentautoackwas removedSubscription#wait_for_messagesmethod argumentautoackwas removed