@@ -44,6 +44,8 @@ class WorkerComponent(Middleware):
4444
4545 _config : Config
4646
47+ _bindToEventExchange : bool
48+
4749 def __init__ (
4850 self ,
4951 route : str ,
@@ -65,6 +67,11 @@ def __init__(
6567 self ._bus = bus
6668 self ._cache = cache
6769 self ._config = config
70+ self ._bindToEventExchange = (
71+ config .get ("conf.bus.bindtoeventexchange" )
72+ if len (self ._eventResolvers .keys ()) > 0
73+ else False
74+ )
6875
6976 self ._resolvers ["healthz" ] = lambda * args : HEALTHZ (* args )
7077
@@ -84,10 +91,18 @@ def _close(self):
8491 def connect (self ):
8592 super ().connect ()
8693
94+ print ("Consumer now Subscribing" , flush = True )
95+ print (" Route:" , self ._route , flush = True )
96+ print (" InstanceId:" , self ._instanceId , flush = True )
97+ print (" Resolvers:" , self ._resolvers .keys (), flush = True )
98+ print (" Event Resolvers:" , self ._eventResolvers .keys (), flush = True )
99+ print (" Bind to Event Exchange:" , self ._bindToEventExchange , flush = True )
100+
87101 self ._bus .subscribe (
88102 self ._route ,
89103 self .inputProcessor ,
90104 self ._onConsuming ,
105+ bindEventExchange = self ._bindToEventExchange ,
91106 )
92107
93108 def emitEvent (self , eventName : str , details : Any ):
@@ -173,14 +188,12 @@ def inputProcessor(self, message: Any) -> StatusCode:
173188 artifact ["inputs" ],
174189 self ._children ,
175190 )
176- cache .setKey (message ["id" ], getAnswerArtifact (
177- message ["id" ], response ))
191+ cache .setKey (message ["id" ], getAnswerArtifact (message ["id" ], response ))
178192 return StatusCode .OK
179193 except Exception as e :
180194 cache .setKey (
181195 message ["id" ],
182- getErrorArtifact (message ["id" ], str (
183- e ), StatusCode .SERVER_ERROR ),
196+ getErrorArtifact (message ["id" ], str (e ), StatusCode .SERVER_ERROR ),
184197 )
185198 return StatusCode .SERVER_ERROR
186199
0 commit comments