SlideShare a Scribd company logo
1 of 5
Download to read offline
Below I have 2 microservices that compile very well. I need help integrating these microservices
using zeromq. I would like to use ticker.py to call the other microservice ( server.py &
client.py).
Thank you!
ticker.py
import sys
import tkinter
import zmq
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
print("Connecting to the Stock Ticker Symbol Server......")
message = socket.recv()
print("The company's stock ticker symbol is:", message.decode())
companies = [
None,
"Apple Inc.",
"Microsoft Corp.",
"Amazon.com Inc.",
"Facebook Inc.",
"Berkshire Hathaway Inc.",
"Google (aka Alphabet Inc.)"
]
tickers = [
None,
"AAPL",
"MSFT",
"AMZN",
"FB",
"BRK",
"GOOG"
]
root = tkinter.Tk()
root.title("Stock ticker symbols")
#labels
compLabel = tkinter.Label(text = "Choose company name:", anchor = "w",padx = 20)
compLabel.grid(row = 0, column = 0)
mytikLabel = tkinter.Label(text = "Ticker:", anchor = "e",padx = 5)
mytikLabel.grid(row = 2, column = 0)
tikLabel = tkinter.Label(anchor = "e", pady = 10, padx = 40, bg = "white", fg = "green", font =
20)
tikLabel.grid(row = 2, column = 1, sticky = "e")
#Variables:
com = tkinter.StringVar(root)
com.set(companies[1]) #default value
#menu
def erase(companies):
tikLabel["text"] = ""
compMenu = tkinter.OptionMenu(root, com, *companies[1:], command = erase)
compMenu.grid(row = 0, column = 1, sticky = "ew")
#button
def fetchticker():
select = com.get()
for ticker in tickers:
if select == companies[1]:
tik = tickers[1]
elif select == companies[2]:
tik = tickers[2]
elif select == companies[3]:
tik = tickers[3]
elif select == companies[3]:
tik = tickers[3]
elif select == companies[4]:
tik = tickers[4]
elif select == companies[5]:
tik = tickers[5]
elif select == companies[6]:
tik = tickers[6]
tikLabel["text"] = tik
button = tkinter.Button(root, text = "Fetch ticker symbol",
anchor = "e", padx = 20, pady = 5, command = fetchticker, bg = "red", fg="white")
button.grid(row = 1, column = 1, sticky = "e")
tkinter.mainloop()
server.py
import zmq
import time
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")
def get_company_name(ticker_symbol):
ticker_to_company = {"AAPL": "Apple Inc.", "GOOG": "Alphabet Inc.", "MSFT": "Microsoft
Corporation"}
return ticker_to_company.get(ticker_symbol, "Unknown")
while True:
ticker_symbol = socket.recv().decode()
time.sleep(1)
company_name = get_company_name(ticker_symbol)
socket.send(company_name.encode())
client.py
import zmq
context = zmq.Context()
# Socket to talk to server
print("Connecting to hello world server...")
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
print(f"Current libzmq version is {zmq.zmq_version()}")
print(f"Current pyzmq version is {zmq.__version__}")
# Do 10 requests, waiting each time for a response
for request in range(1):
print(f"Sending request {request} ...")
socket.send_string("GOOG")
# Get the reply.
message = socket.recv()
print(f"Received reply {request} [ {message} ]")

More Related Content

Similar to Below I have 2 microservices that compile very well- I need help inte.pdf

Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
fisher.w.y
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
adianantsolutions
 

Similar to Below I have 2 microservices that compile very well- I need help inte.pdf (20)

Cc code cards
Cc code cardsCc code cards
Cc code cards
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
PyLecture2 -NetworkX-
PyLecture2 -NetworkX-PyLecture2 -NetworkX-
PyLecture2 -NetworkX-
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Add an interactive command line to your C++ application
Add an interactive command line to your C++ applicationAdd an interactive command line to your C++ application
Add an interactive command line to your C++ application
 
The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84
 
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185
 
Gans
GansGans
Gans
 
GANs
GANsGANs
GANs
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181
 
R Language
R LanguageR Language
R Language
 
Sentiment analysis- Modi, Trump, Putin
Sentiment analysis- Modi, Trump, PutinSentiment analysis- Modi, Trump, Putin
Sentiment analysis- Modi, Trump, Putin
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 

More from rdzire2014

Below are questions that use the following image class- import assert.pdf
Below are questions that use the following image class-  import assert.pdfBelow are questions that use the following image class-  import assert.pdf
Below are questions that use the following image class- import assert.pdf
rdzire2014
 
Being able to connect to the Internet is crucial for Canada's northern.pdf
Being able to connect to the Internet is crucial for Canada's northern.pdfBeing able to connect to the Internet is crucial for Canada's northern.pdf
Being able to connect to the Internet is crucial for Canada's northern.pdf
rdzire2014
 

More from rdzire2014 (20)

Below is a pedigree for a family where several members (labeled in bla (1).pdf
Below is a pedigree for a family where several members (labeled in bla (1).pdfBelow is a pedigree for a family where several members (labeled in bla (1).pdf
Below is a pedigree for a family where several members (labeled in bla (1).pdf
 
Below is a llst of balances for S- Jones- a sole treder- for the year.pdf
Below is a llst of balances for S- Jones- a sole treder- for the year.pdfBelow is a llst of balances for S- Jones- a sole treder- for the year.pdf
Below is a llst of balances for S- Jones- a sole treder- for the year.pdf
 
Below are two very simple profiles of volcanoes (A - a shield volcano-.pdf
Below are two very simple profiles of volcanoes (A - a shield volcano-.pdfBelow are two very simple profiles of volcanoes (A - a shield volcano-.pdf
Below are two very simple profiles of volcanoes (A - a shield volcano-.pdf
 
Below are a few descriptions of various components of the lymphatic sy.pdf
Below are a few descriptions of various components of the lymphatic sy.pdfBelow are a few descriptions of various components of the lymphatic sy.pdf
Below are a few descriptions of various components of the lymphatic sy.pdf
 
Below are images taken at different time points of a cell undergoing m.pdf
Below are images taken at different time points of a cell undergoing m.pdfBelow are images taken at different time points of a cell undergoing m.pdf
Below are images taken at different time points of a cell undergoing m.pdf
 
Below are questions that use the following image class- import assert.pdf
Below are questions that use the following image class-  import assert.pdfBelow are questions that use the following image class-  import assert.pdf
Below are questions that use the following image class- import assert.pdf
 
Below are 4 water-balance diagrams for different areas of the world- L.pdf
Below are 4 water-balance diagrams for different areas of the world- L.pdfBelow are 4 water-balance diagrams for different areas of the world- L.pdf
Below are 4 water-balance diagrams for different areas of the world- L.pdf
 
Being able to connect to the Internet is crucial for Canada's northern.pdf
Being able to connect to the Internet is crucial for Canada's northern.pdfBeing able to connect to the Internet is crucial for Canada's northern.pdf
Being able to connect to the Internet is crucial for Canada's northern.pdf
 
Below are data for a hypothetical country that produces three goods- r.pdf
Below are data for a hypothetical country that produces three goods- r.pdfBelow are data for a hypothetical country that produces three goods- r.pdf
Below are data for a hypothetical country that produces three goods- r.pdf
 
Beginning in the year 2018 - the net asset classifications temporarily.pdf
Beginning in the year 2018 - the net asset classifications temporarily.pdfBeginning in the year 2018 - the net asset classifications temporarily.pdf
Beginning in the year 2018 - the net asset classifications temporarily.pdf
 
Before we prepare our sample for Transmission Electron Microscopy (TEM.pdf
Before we prepare our sample for Transmission Electron Microscopy (TEM.pdfBefore we prepare our sample for Transmission Electron Microscopy (TEM.pdf
Before we prepare our sample for Transmission Electron Microscopy (TEM.pdf
 
Before we can perform the task of subtotal- what needs to be done firs.pdf
Before we can perform the task of subtotal- what needs to be done firs.pdfBefore we can perform the task of subtotal- what needs to be done firs.pdf
Before we can perform the task of subtotal- what needs to be done firs.pdf
 
Bees are haplodiploid- meaning that females are diploid and males are.pdf
Bees are haplodiploid- meaning that females are diploid and males are.pdfBees are haplodiploid- meaning that females are diploid and males are.pdf
Bees are haplodiploid- meaning that females are diploid and males are.pdf
 
bee probuced by Tactory l is ostetive n0oct1 Mhiser.pdf
bee probuced by Tactory l is ostetive n0oct1 Mhiser.pdfbee probuced by Tactory l is ostetive n0oct1 Mhiser.pdf
bee probuced by Tactory l is ostetive n0oct1 Mhiser.pdf
 
Because of their great versatility- bacteria may obtain compounds esse.pdf
Because of their great versatility- bacteria may obtain compounds esse.pdfBecause of their great versatility- bacteria may obtain compounds esse.pdf
Because of their great versatility- bacteria may obtain compounds esse.pdf
 
Because conflicts of interest increase asymmetric information problems.pdf
Because conflicts of interest increase asymmetric information problems.pdfBecause conflicts of interest increase asymmetric information problems.pdf
Because conflicts of interest increase asymmetric information problems.pdf
 
BE10-11 (LO 4) In its recent annual report- Campbell Soup Company repo.pdf
BE10-11 (LO 4) In its recent annual report- Campbell Soup Company repo.pdfBE10-11 (LO 4) In its recent annual report- Campbell Soup Company repo.pdf
BE10-11 (LO 4) In its recent annual report- Campbell Soup Company repo.pdf
 
Biotechnology Microbial Solutions- 1- Describe current examples in bio.pdf
Biotechnology Microbial Solutions- 1- Describe current examples in bio.pdfBiotechnology Microbial Solutions- 1- Describe current examples in bio.pdf
Biotechnology Microbial Solutions- 1- Describe current examples in bio.pdf
 
Be sure to show work for 4-6- One way that astronomers detect exopla.pdf
Be sure to show work for 4-6-   One way that astronomers detect exopla.pdfBe sure to show work for 4-6-   One way that astronomers detect exopla.pdf
Be sure to show work for 4-6- One way that astronomers detect exopla.pdf
 
Be able to quickly describe and - or diagram the net flow of water (in.pdf
Be able to quickly describe and - or diagram the net flow of water (in.pdfBe able to quickly describe and - or diagram the net flow of water (in.pdf
Be able to quickly describe and - or diagram the net flow of water (in.pdf
 

Recently uploaded

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Recently uploaded (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Below I have 2 microservices that compile very well- I need help inte.pdf

  • 1. Below I have 2 microservices that compile very well. I need help integrating these microservices using zeromq. I would like to use ticker.py to call the other microservice ( server.py & client.py). Thank you! ticker.py import sys import tkinter import zmq context = zmq.Context() socket = context.socket(zmq.REQ) socket.connect("tcp://localhost:5555") print("Connecting to the Stock Ticker Symbol Server......") message = socket.recv() print("The company's stock ticker symbol is:", message.decode()) companies = [ None, "Apple Inc.", "Microsoft Corp.", "Amazon.com Inc.", "Facebook Inc.", "Berkshire Hathaway Inc.", "Google (aka Alphabet Inc.)" ] tickers = [
  • 2. None, "AAPL", "MSFT", "AMZN", "FB", "BRK", "GOOG" ] root = tkinter.Tk() root.title("Stock ticker symbols") #labels compLabel = tkinter.Label(text = "Choose company name:", anchor = "w",padx = 20) compLabel.grid(row = 0, column = 0) mytikLabel = tkinter.Label(text = "Ticker:", anchor = "e",padx = 5) mytikLabel.grid(row = 2, column = 0) tikLabel = tkinter.Label(anchor = "e", pady = 10, padx = 40, bg = "white", fg = "green", font = 20) tikLabel.grid(row = 2, column = 1, sticky = "e") #Variables: com = tkinter.StringVar(root) com.set(companies[1]) #default value #menu def erase(companies):
  • 3. tikLabel["text"] = "" compMenu = tkinter.OptionMenu(root, com, *companies[1:], command = erase) compMenu.grid(row = 0, column = 1, sticky = "ew") #button def fetchticker(): select = com.get() for ticker in tickers: if select == companies[1]: tik = tickers[1] elif select == companies[2]: tik = tickers[2] elif select == companies[3]: tik = tickers[3] elif select == companies[3]: tik = tickers[3] elif select == companies[4]: tik = tickers[4] elif select == companies[5]: tik = tickers[5] elif select == companies[6]: tik = tickers[6] tikLabel["text"] = tik button = tkinter.Button(root, text = "Fetch ticker symbol",
  • 4. anchor = "e", padx = 20, pady = 5, command = fetchticker, bg = "red", fg="white") button.grid(row = 1, column = 1, sticky = "e") tkinter.mainloop() server.py import zmq import time context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") def get_company_name(ticker_symbol): ticker_to_company = {"AAPL": "Apple Inc.", "GOOG": "Alphabet Inc.", "MSFT": "Microsoft Corporation"} return ticker_to_company.get(ticker_symbol, "Unknown") while True: ticker_symbol = socket.recv().decode() time.sleep(1) company_name = get_company_name(ticker_symbol) socket.send(company_name.encode()) client.py import zmq context = zmq.Context()
  • 5. # Socket to talk to server print("Connecting to hello world server...") socket = context.socket(zmq.REQ) socket.connect("tcp://localhost:5555") print(f"Current libzmq version is {zmq.zmq_version()}") print(f"Current pyzmq version is {zmq.__version__}") # Do 10 requests, waiting each time for a response for request in range(1): print(f"Sending request {request} ...") socket.send_string("GOOG") # Get the reply. message = socket.recv() print(f"Received reply {request} [ {message} ]")