Haha, you are such a positive person, I believe the people around you are very lucky because they always see your smile and it is energizing. You are truly an example of a happy life. Thanks for the smile
I've read and re-read this comment more than any other comment on any video I've ever made. I can't thank you enough for reaching out and being so kind. The only reason I haven't replied to it is because RU-vid only shows me a list of unread ones, and I wanted to see this note over and over again Thanks, Ryan
Hey Oleg, sorry to respond so late! You'll need to use `futures`. The answer on this page has good code stackoverflow.com/questions/69307567/how-to-publish-multiple-messages-in-google-pub-sub-fast
good one ! as for the json data, I guess you could also serialize it with json.dumps on the publisher side to convert JSON to a string and then json.loads on the subscriber?
Your question is surprisingly intricate. There's a "yes" part to it and a "no" part as well. "Yes" they are the same - it's all Google Cloud, but not 100% the same because you can access Firebase without needing to work in Google Cloud. Firebase is a GCP offering, and it relies on the Google Cloud for all of its own hardware. When we're billed for using Firebase, we're charged for Google Cloud storage, too. But Firebase was a separate company that Google bought, and they try to keep their identity a little bit distinct, too. But slowly, Google Cloud is incorporating it as if it was the faster, younger sibling of BigTable :)
Hi Ryan Thanks for the video, this is very informative. I have a question and wondering if you could help with this. How do we set up email notifications to multiple users who subscribe to a topic? This is fairly simple on AWS, we just choose email as protocol for the Subscription and add the user's email address. How do we set this up in GCP Pub/Sub? Thanks in advance
Hi Anu, I found the walkthrough for you. I knew that Google Cloud doesn’t natively have a mail sender, but this link has the code for you cloud.google.com/security-command-center/docs/how-to-enable-real-time-notifications also, I’ll add this to my list of future videos, so thanks for the idea!
Do you know how to use pub/sub using future ? Is there any way to use a subscriber without blocking the code? I mean start doing stuff and just ask when there is an actual message in the topic?
Hey Santiago, that's an interesting and useful question. Here's the code adding concurrency and futures :) scroll to the bottom levelup.gitconnected.com/how-to-use-google-pub-sub-to-build-an-asynchronous-messaging-system-in-python-3b43094627dc
hey man! I am working on this django microservice project and I wanted to use pub/sub for my inter service communication but since my services are running on cloud run I can not use pull subscription since I can not run both celery and django in one cloud run so I was thinking it would be better to use push subscription can you please point me to some direction pls?
Hummmmm.. we’ll I just finished using Apache Kafka which is like pubsub on steroids. But really, if you need to push, I’d use Cloud Functions in Python (I’ve got a video on it, and it’s powerful, but you have to build everything from scratch)
@@d-i-ry Thankyou sir, One more question can i have video to sink cloud logging with Big query dataset (table) updates and that will publish a message in a defined topic which is subcribed and triggers cloud function
hi @@cloudlover9186 this one sounds a little bit intricate. i can definitely help you with the steps, but I'm a little confused. what are you hoping to do?
Thank you so much for the video. Do you think I can have a Python server that listens to the pubsub events? Should I use Django or Flask for that? I want to host a Python server that listens to GCP Pubsub events and handle the incoming events.
Hi Sim, I like Flask because of how many tutorials there are, and because of how easy it is to start up a small server. Your project sounds fun :) good luck :)
Nice tutorial, Ryan. I only have one doubt, when I open two subscribers the message works as if it were distributed, instead of reaching the two subscribers at the same time. Do you know how to solve this?
Hey thanks Gustavo! That’s how they’ve made PubSub work, as if it’s distributed. If you need to sync actions, PubSub won’t be able to do that, but there are a bunch of other services that can. My favorite is Firebase Cloud Firestore. You can have any number of listeners, and they’ll all receive the update at the same time. You can even integrate PubSub with Firebase (I think I did 2 videos on that a while back)
Hi Lee Jun Ming, I'm glad you got it running on your own machine! I haven't played with Cloud Run I actually misread your question, and wrote a long solution for Cloud Functions instead of Cloud Run. But here's something that might help you... cloud.google.com/run/docs/testing/local When I need to build a Cloud Function, I test locally first. I hope that can be of help when you build a Cloud Run environment, too. Good luck!
Hi Rayan, I have one doubt regarding authentication of service account. When I try to use gcloud auth activate-service-account account name keyfile=key.jason, am getting error as gcloud crashed
Hey mate, how can I get the pub sub private key to connect from an external service? Let's say that I wanna have the pub sub as my backend service and I wanna send message from my application to pub sub... Would I have to create a Service Account pointing to the Pub Sub topic and I would use the Service Account Key to access Pub Sub? Cheers for the help mate!
Hey Rafael, that’s the exact way I’d do it. I know that my BigQuery in Python video shows the steps to make that service account and link the JSON key (it’s a real short video)
Hi Ryan, the subscriber type which you used in this video is Pull type. Could you please help me how to publish messages if the subscriber type is Push. If there is any python code to publish messages to push type subscription, that would be great.
Hi Rahul, check this article out cloud.google.com/pubsub/docs/push you want to keep your message senders and message receivers nice and simple… pull subscribers listen and receive, and push subscribers speak to the server and send messages :)
Hi Scott, I rewatched the video and I didn’t see any reference to “path”. Did I update the code that way? There should be a topic_path for the publisher to write to and a subscription_path for the subscriber to listen on
Huh…. I don’t know. I think there’s a few things to consider. The answer’s probably “no” on this first question, but just to ask, can the 2 functions be combined? One thing I wouldn’t want to do even though it’d be easy is to make 2 pubsub topics and write to both. 1 cloud function listens to 1 topic, the other listens to the 2nd topic. And the reason I don’t like that is because you can’t guarantee which is acted on in what order. Can you share some more details?
Oh I might have started off on the wrong foot. Do you want the 2 cloud functions to talk directly between each other? Like they need to share info and it’s not necessarily coming from a 3rd source they’re listening to?
This might be a little over-engineered, but could you let them read and write to Firebase? I think I made a cloud-function-to-Firebase video that would help if that idea’s not tooooo much extra work The problem for me with cloud functions is they’re stateless, so they can’t retain info (or state), so my immediate thought is to let them read and write to a database
Hi Muhammad, parameter unpacking is a way of sending multiple parameters to a function, all wrapped in a list or dictionary. Suppose your function looks like this: def sum(a, b, c): return a + b + c and you normally call it like this: result = sum(1, 2, 3) but you can also send a "packed" list (or dictionary) of parameters my_values = [1, 2, 3] result = sum(*my_values) the star * will "unpack" the variables for you. it'll turn your 1 list into the 3 input parameters. Keep in mind that if your list has more values than your function is expecting, there'll be an error take a look at the answer from "Lorin Hochstein" (with about 753 votes right now) here stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters Lists use 1 star *my_values Dictionaries use 2 stars **my_values, because the first * gets each key-value pair, and the second * gets the individual keys (you'll need to extract the values with the keys you've just been given) :)
@@gurudattshet6914 www.python.org/downloads/ download Python 3 from here :) you should really only use Python 2 instead of Python 3 these days if there's a specific reason (like "the project started in Python 2 and it would take too much time to rewrite it in Python 3" or "this library only works in Python 2 but not in 3"). And not to worry, I keep all the code simple to understand. If you're comfortable in Python 2, you can follow my project in Python 3 without any problems :)
@@meredithhoo2312 sorry, im still lost cause I thought this video shows that topic. can you explain an example of what you want to see with message pushing? btw, if I describe PubSub in another way, it's like talking in front of a tv camera. the publisher (the speaker) has no idea if anyone is watching. so if you're looking for a delivery guarantee --- like pushing directly to a specific computer --- that's not something PubSub is able to do
@@meredithhoo2312 AHHH! that's correct. PubSub is a passive system. There are only pulls, not pushes. But pulling and pushing can take on a few meanings.... sometimes people mean "passive" listening systems for "pull" and they mean "active" systems for "push". In PubSub, the message pusher is the message publisher. the message puller is the listener or message consumer. PubSub's a passive message system, which means that there's no guarantee the message being produced will ever be consumed. There could be no one listening to the message topic. All the code for the publisher (in my link in the description) is the code for message pushing. I hope that helps :)
@@darkdeathoriginal download your service account's credentials in a JSON key file, then add this code: from google.oauth2 import service_account key_path = "/path/to/your/service-account-file.json" credentials = service_account.Credentials.from_service_account_file(key_path) publisher = pubsub_v1.PublisherClient(credentials=credentials) subscriber = pubsub_v1.SubscriberClient(credentials=credentials) :)