(Migrated) fan out pattern parameters and SIO service

(This message has been automatically imported from the retired mailing list)

I don’t know if this is a bug, or I’m just doing it wrong.

I have the following service using the fanout pattern:

class TestFanoutService(Service):
def handle(self):

    params = {
        'domain’:  ‘google',
        'extra': “",
        'callback': “"
    }
    targets = {
        'sio-fanout-test.test-service': params

    }

    callbacks = ['sio-fanout-result.test-service']
    cid = self.patterns.fanout.invoke(targets, callbacks)

and this is the service that is being invoked:

class TestService(Service):
class SimpleIO:
input_required = (‘domain’,)
input_optional = (‘extra’, ‘callback’)

def handle(self):
    self.logger.info(self.request.raw_request)

but I’m getting this error:

2015-07-14 12:12:27,779 - ERROR - zato.server.base:22 - Could not handle broker msg:[Bunch(action=u’101802’, callback=None, channel=u’fanout-call’, cid=u’K0469BX8YVVAF7MWXHQFBVKZK7BQ’, data_format=u’dict’, environ={}, is_async=True, msg_type=u’0001’, payload=u’{“domains”: “google.com”, “callback”: “”, “extra”: “”}’, service=u’sio-fanout-test.test-service’, transport=None, zato_ctx={u’fanout_cid’: u’K05G6G1NQJJGG3Q63CDTZ3C1ESTW’, u’zato.request_ctx.target’: u’’})], e:[Traceback (most recent call last):
File “/opt/zato/2.0.5/zato-server/src/zato/server/service/reqresp/sio.py”, line 356, in convert_from_json
return (payload or {}).get(param_name, NOT_GIVEN)
AttributeError: ‘unicode’ object has no attribute ‘get’

doing a service invoke works as expected:

response = self.invoke(‘sio-fanout-test.test-service’, params, as_bunch=True)

log:
2015-07-14 12:22:56,572 - INFO - sio-fanout-test.test-service:22 - {u’callback’: u’’, u’domain’: u’google.com’, u’extra’: u’’}

As a workaround I’ve passed the data as json and removed the SIO part on the service that is being called, it works but now I have to use only json for that service

Hi,
I’m not sure it is the same problem, but I had a similar issue where I
used SIO in a service that didn’t always return results,
so as workaround in case there are no results I just did:

self.response.payload[:] = []

On 14/07/15 21:29, Ivan Villareal wrote:

I don’t know if this is a bug, or I’m just doing it wrong.

I have the following service using the fanout pattern:

class TestFanoutService(Service):
def handle(self):

     params = {
         'domain’:  ‘google',
         'extra': “",
         'callback': “"
     }
     targets = {
         'sio-fanout-test.test-service': params

     }

     callbacks = ['sio-fanout-result.test-service']
     cid = self.patterns.fanout.invoke(targets, callbacks)

and this is the service that is being invoked:

class TestService(Service):
class SimpleIO:
input_required = (‘domain’,)
input_optional = (‘extra’, ‘callback’)

 def handle(self):
     self.logger.info(self.request.raw_request)

but I’m getting this error:

2015-07-14 12:12:27,779 - ERROR - zato.server.base:22 - Could not handle broker msg:[Bunch(action=u’101802’, callback=None, channel=u’fanout-call’, cid=u’K0469BX8YVVAF7MWXHQFBVKZK7BQ’, data_format=u’dict’, environ={}, is_async=True, msg_type=u’0001’, payload=u’{“domains”: “google.com”, “callback”: “”, “extra”: “”}’, service=u’sio-fanout-test.test-service’, transport=None, zato_ctx={u’fanout_cid’: u’K05G6G1NQJJGG3Q63CDTZ3C1ESTW’, u’zato.request_ctx.target’: u’’})], e:[Traceback (most recent call last):
File “/opt/zato/2.0.5/zato-server/src/zato/server/service/reqresp/sio.py”, line 356, in convert_from_json
return (payload or {}).get(param_name, NOT_GIVEN)
AttributeError: ‘unicode’ object has no attribute ‘get’

doing a service invoke works as expected:

response = self.invoke(‘sio-fanout-test.test-service’, params, as_bunch=True)

log:
2015-07-14 12:22:56,572 - INFO - sio-fanout-test.test-service:22 - {u’callback’: u’’, u’domain’: u’google.com’, u’extra’: u’’}

As a workaround I’ve passed the data as json and removed the SIO part on the service that is being called, it works but now I have to use only json for that service

I’ve tried adding this but I’m getting the same error,

I’ve also added a fixed output with the same results.

On Jul 14, 2015, at 10:31 PM, Andrea Peter pedrudehuere@hotmail.com wrote:

Hi,
I’m not sure it is the same problem, but I had a similar issue where I used SIO in a service that didn’t always return results,
so as workaround in case there are no results I just did:

self.response.payload[:] = []

On 14/07/15 21:29, Ivan Villareal wrote:

I don’t know if this is a bug, or I’m just doing it wrong.

I have the following service using the fanout pattern:

class TestFanoutService(Service):
def handle(self):

    params = {
        'domain’:  ‘google',
        'extra': “",
        'callback': “"
    }
    targets = {
        'sio-fanout-test.test-service': params

    }

    callbacks = ['sio-fanout-result.test-service']
    cid = self.patterns.fanout.invoke(targets, callbacks)

and this is the service that is being invoked:

class TestService(Service):
class SimpleIO:
input_required = (‘domain’,)
input_optional = (‘extra’, ‘callback’)

def handle(self):
    self.logger.info(self.request.raw_request)

but I’m getting this error:

2015-07-14 12:12:27,779 - ERROR - zato.server.base:22 - Could not handle broker msg:[Bunch(action=u’101802’, callback=None, channel=u’fanout-call’, cid=u’K0469BX8YVVAF7MWXHQFBVKZK7BQ’, data_format=u’dict’, environ={}, is_async=True, msg_type=u’0001’, payload=u’{“domains”: “google.com”, “callback”: “”, “extra”: “”}’, service=u’sio-fanout-test.test-service’, transport=None, zato_ctx={u’fanout_cid’: u’K05G6G1NQJJGG3Q63CDTZ3C1ESTW’, u’zato.request_ctx.target’: u’’})], e:[Traceback (most recent call last):
File “/opt/zato/2.0.5/zato-server/src/zato/server/service/reqresp/sio.py”, line 356, in convert_from_json
return (payload or {}).get(param_name, NOT_GIVEN)
AttributeError: ‘unicode’ object has no attribute ‘get’

doing a service invoke works as expected:

response = self.invoke(‘sio-fanout-test.test-service’, params, as_bunch=True)

log:
2015-07-14 12:22:56,572 - INFO - sio-fanout-test.test-service:22 - {u’callback’: u’’, u’domain’: u’google.com’, u’extra’: u’’}

As a workaround I’ve passed the data as json and removed the SIO part on the service that is being called, it works but now I have to use only json for that service