Hi Matt, I'm having some trouble with this. The idea is that when I catch
the exception with the worker_result, I want to publish a message in the
exchange called ErrorExchange. I have this code:
import traceback
from kombu.messaging import Exchange
from nameko.extensions import DependencyProvider
from nameko.messaging import Publisher
error_exchange = Exchange("ErrorExchange", type='fanout')
class ErrorHandler(DependencyProvider):
p = Publisher(exchange=error_exchange)
def worker_result(self, worker_ctx, res, exc_info):
if exc_info is None:
return # nothing to do
exc_type, exc, tb = exc_info
msg = { "message": str(exc_info), "stack":
traceback.format_tb(tb), "type": str(exc_type) }
self.p(msg) #Publish message in the exchange
But when I try to run, I get this error:
(cn) am@VdiUB-02:~/Projects/utils/cn$ nameko run notificationcenter
--broker amqp://guest:guest@localhost
Traceback (most recent call last):
File "/home/am/Projects/venv/cn/bin/nameko", line 11, in <module>
sys.exit(main())
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/cli/main.py",
line 62, in main
args.main(args)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/cli/commands.py",
line 85, in main
main(args)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/cli/run.py",
line 181, in main
run(services, config, backdoor_port=args.backdoor_port)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/cli/run.py",
line 116, in run
service_runner.add_service(service_cls)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/runners.py",
line 70, in add_service
container = self.container_cls(cls, self.config, worker_ctx_cls)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/containers.py",
line 156, in __init__
bound = dependency.bind(self.interface, attr_name)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/extensions.py",
line 145, in bind
instance = super(DependencyProvider, self).bind(container)
File
"/home/am/Projects/venv/cn/lib/python3.5/site-packages/nameko/extensions.py",
line 100, in bind
setattr(instance, name, ext.bind(container))
TypeError: bind() missing 1 required positional argument: 'attr_name'
Since I don't find any documentation about publishers and consumer, I
follow the steps I found in here
<Redirecting to Google Groups.
But I still don't know what I'm missing...
Thanks in advance!
Alfonso
ยทยทยท
On Friday, April 7, 2017 at 4:24:44 PM UTC+2, alfo...@gmail.com wrote:
That's it! Thank you Matt!
On Thursday, April 6, 2017 at 1:33:53 PM UTC+2, alfo...@gmail.com wrote:
Hi, I'm trying to use Nameko for the creation of a simple notification
center that sends emails consuming from several queues in RabbitMQ.
Our whole architecture is service based and we have a system to write the
exceptions of every service in our database that are queued in a different
queue in Rabbit too. Is there a way to handle the exceptions that raise
during a worker job? I notice that they are logged and the service is still
running. But what I want is to publish a message in the Error queue when an
exception raises besides the log. I've tried with sys.excepthook and raised
an exception on purpose but the exception was catched before it could be
handled by the excepthook. Any ideas?
Thanks in advance!
Alfonso