Skip to content
Snippets Groups Projects
Commit b8a4d393 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8888: use optional other broker in RPC

parent 0efbb80f
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ class RPC(): ...@@ -69,7 +69,7 @@ class RPC():
As a side-effect the sender and session are destroyed. As a side-effect the sender and session are destroyed.
""" """
def __init__(self, service, **kwargs ): def __init__(self, service, broker=None, **kwargs ):
""" """
Initialize an Remote procedure call using: Initialize an Remote procedure call using:
service= <str> Service Name service= <str> Service Name
...@@ -84,11 +84,12 @@ class RPC(): ...@@ -84,11 +84,12 @@ class RPC():
self.ForwardExceptions = kwargs.pop("ForwardExceptions", False) self.ForwardExceptions = kwargs.pop("ForwardExceptions", False)
self.Verbose = kwargs.pop("Verbose", False) self.Verbose = kwargs.pop("Verbose", False)
self.BusName = kwargs.pop("busname", None) self.BusName = kwargs.pop("busname", None)
self.ServiceName = service self.ServiceName = service
self.broker = broker
if self.BusName is None: if self.BusName is None:
self.Request = ToBus(self.ServiceName) self.Request = ToBus(self.ServiceName, broker=self.broker)
else: else:
self.Request = ToBus("%s/%s" % (self.BusName, self.ServiceName)) self.Request = ToBus("%s/%s" % (self.BusName, self.ServiceName), broker=self.broker)
if len(kwargs): if len(kwargs):
raise AttributeError("Unexpected argument passed to RPC class: %s" %( kwargs )) raise AttributeError("Unexpected argument passed to RPC class: %s" %( kwargs ))
...@@ -122,9 +123,9 @@ class RPC(): ...@@ -122,9 +123,9 @@ class RPC():
options = {'create':'always','delete':'receiver'} options = {'create':'always','delete':'receiver'}
ReplyAddress = "reply.%s" % (str(uuid.uuid4())) ReplyAddress = "reply.%s" % (str(uuid.uuid4()))
if self.BusName is None: if self.BusName is None:
Reply = FromBus("%s ; %s" %(ReplyAddress,str(options))) Reply = FromBus("%s ; %s" %(ReplyAddress,str(options)), broker=self.broker)
else: else:
Reply = FromBus("%s/%s" % (self.BusName, ReplyAddress)) Reply = FromBus("%s/%s" % (self.BusName, ReplyAddress), broker=self.broker)
with Reply: with Reply:
MyMsg = RequestMessage(content=Content, reply_to=ReplyAddress, has_args=HasArgs, has_kwargs=HasKwArgs) MyMsg = RequestMessage(content=Content, reply_to=ReplyAddress, has_args=HasArgs, has_kwargs=HasKwArgs)
MyMsg.ttl = timeout MyMsg.ttl = timeout
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment