Package: rejected
Rejected is a AMQP consumer daemon and message processing framework. It allows
for rapid development of message processing consumers by handling all of the
core functionality of communicating with RabbitMQ and management of consumer
processes.Rejected runs as a master process with multiple consumer configurations that are
each run it an isolated process. It has the ability to collect statistical
data from the consumer processes and report on it.Rejected supports Python 2.7 and 3.4+.FeaturesAutomatic exception handling including connection management and consumer restartingSmart consumer classes that can automatically decode and deserialize message bodies based upon message headersMetrics logging and submission to statsd and InfluxDBBuilt-in profiling of consumer codeAbility to write asynchronous code in consumers allowing for parallel communication with external resourcesDocumentationhttps://rejected.readthedocs.ioExample ConsumersfromrejectedimportconsumerimportloggingLOGGER=logging.getLogger(__name__)classTest(consumer.Consumer):defprocess(self,message):LOGGER.debug('In Test.process:%s'%message.body)Async ConsumerTo make a consumer async, you can decorate theConsumer.prepareandConsumer.processmethods using Tornado’s@gen.coroutine.
Asynchronous consumers do not allow for concurrent processing multiple messages in the same process, but
rather allow you to use asynchronous clients likeTornado’sAsyncHTTPClientand theQueriesPostgreSQL library to perform parallel tasks using coroutines when processing a single message.importloggingfromrejectedimportconsumerfromtornadoimportgenfromtornadoimporthttpclientclassAsyncExampleConsumer(consumer.Consumer):@gen.coroutinedefprocess(self):LOGGER.debug('Message:%r',self.body)http_client=httpclient.AsyncHTTPClient()results=yield[http_client.fetch('http://www.github.com'),http_client.fetch('http://www.reddit.com')]LOGGER.info('Length:%r',[len(r.body)forrinresults])Example Configuration%YAML1.2---Application:poll_interval:10.0stats:log:Trueinfluxdb:enabled:Truescheme:httphost:localhostport:8086user:usernamepassword:passworddatabase:dbnamestatsd:enabled:Truehost:localhostport:8125prefix:applications.rejectedConnections:rabbitmq:host:localhostport:5672user:guestpass:guestssl:Falsevhost:/heartbeat_interval:300Consumers:example:consumer:rejected.example.Consumersentry_dsn:https://[YOUR-SENTRY-DSN]connections:-name:rabbitmq1consume:Truedrop_exchange:dlxnameqty:2queue:generated_messagesqos_prefetch:100ack:Truemax_errors:100config:foo:Truebar:bazDaemon:user:rejectedgroup:daemonpidfile:/var/run/rejected/example.%(pid)s.pidLogging:version:1formatters:verbose:format:"%(levelname)-10s%(asctime)s%(process)-6d%(processName)-25s%(name)-20s%(funcName)-25s:%(message)s"datefmt:"%Y-%m-%d%H:%M:%S"verbose_correlation:format:"%(levelname)-10s%(asctime)s%(process)-6d%(processName)-25s%(name)-20s%(funcName)-25s:%(message)s{CID%(correlation_id)s}"datefmt:"%Y-%m-%d%H:%M:%S"syslog:format:"%(levelname)s<PID%(process)d:%(processName)s>%(name)s.%(funcName)s:%(message)s"syslog_correlation:format:"%(levelname)s<PID%(process)d:%(processName)s>%(name)s.%(funcName)s:%(message)s{CID%(correlation_id)s)"filters:correlation:'()':rejected.log.CorrelationFilter'exists':Trueno_correlation:'()':rejected.log.CorrelationFilter'exists':Falsehandlers:console:class:logging.StreamHandlerformatter:verbosedebug_only:falsefilters:[no_correlation]console_correlation:class:logging.StreamHandlerformatter:verbose_correlationdebug_only:falsefilters:[correlation]syslog:class:logging.handlers.SysLogHandlerfacility:daemonaddress:/var/run/syslogformatter:syslogfilters:[no_correlation]syslog_correlation:class:logging.handlers.SysLogHandlerfacility:daemonaddress:/var/run/syslogformatter:syslogfilters:[correlation]loggers:helper:level:INFOpropagate:truehandlers:[console,console_correlation,syslog,syslog_correlation]rejected:level:INFOpropagate:truehandlers:[console,console_correlation,syslog,syslog_correlation]tornado:level:INFOpropagate:truehandlers:[console,console_correlation,syslog,syslog_correlation]disable_existing_loggers:trueincremental:falseVersion HistoryAvailable athttps://rejected.readthedocs.org/en/latest/history.html