Created
August 30, 2018 21:40
-
-
Save claudiokc/2128c980746c0b1d5a44196771127e6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######### | |
from google.cloud import pubsub_v1 | |
from django.conf import settings | |
import os | |
import json | |
profile = os.path.join(settings.BASE_DIR, 'pubsub/service_account_profile.json') | |
search = os.path.join(settings.BASE_DIR, 'pubsub/service_account_search.json') | |
publisher = pubsub_v1.PublisherClient.from_service_account_file(profile) | |
messages_element = {'data': json.dumps({ | |
'profileId':'001', | |
'programId':'0002', | |
'pathwayId':'11' | |
}).encode()} | |
messages = [messages_element] | |
topic_path = publisher.topic_path('liu-profile-api-qa', 'complete-pathway') | |
publisher.publish(topic_path, messages) | |
publisher = pubsub_v1.PublisherClient() | |
topic_path = publisher.topic_path('liu-search-api-dev', 'newsindexing') | |
data = u'Di algo: {}'.format('hola mundo').encode('utf-8') | |
publisher.publish(topic_path, data=data) | |
######## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment