# Path: tests/settings.py
# USER_SETTINGS = {
#     'VHOST': 'hedwig_server',
#     'USERNAME': 'hedwig_test',
#     'PASSWORD': 'hedwig_pass',
#     'CONSUMER': {
#         'RAISE_EXCEPTION': True,
#         'QUEUES': {
#             'everything_printer': {
#                 'BINDINGS': ['#'],
#                 'CALLBACK': 'tests.callbacks.printer',
#                 'DURABLE': False,
#                 'AUTO_DELETE': True,
#                 'NO_ACK': True
#             },
#             # 'accounts_catch_all': {
#             #     'BINDINGS': ['accounts.#'],
#             #     'CALLBACK': 'tests.callbacks.accounts_printer',
#             #     'DURABLE': False,
#             #     'AUTO_DELETE': True,
#             #     'NO_ACK': True
#             # },
#             # 'message_create': {
#             #     'BINDINGS': ['message.serializer.create.*'],
#             #     'CALLBACK': 'tests.callbacks.message_printer',
#             #     'DURABLE': False,
#             #     'AUTO_DELETE': True,
#             #     'NO_ACK': True
#             # }
#         }
#     }
# }
# 
# Path: hedwig/core/emitter.py
# class Emitter(Base):
#     def emit(self, key, message):
#         """
#          Emits a message to RabbitMQ
# 
#         :param key: Routing key to emit on
#         :param message: json serialized msg body
#         :return:
#         :raises Exception: If RAISE_EXCEPTION is true in emitter settings
#         """
#         try:
#             self._emit(key, message)
#         except ConnectionClosed:
#             self.shutdown()
#             self._emit(key, message)
#         except Exception as e:
#             LOGGER.exception("Emitter exception %s" % str(e))
#             if self.settings.EMITTER['RAISE_EXCEPTION']:
#                 raise
# 
#     def _emit(self, key, message):
#         pub_channel = self.get_channel()
#         LOGGER.debug("Trying to emit - %s" % message)
#         if pub_channel.basic_publish(exchange=self.settings.EXCHANGE, routing_key=key, body=message):
#             LOGGER.info("Emitted - %s" % message)
#         else:
#             LOGGER.error("Failed to emit - %s" % message)


from .settings import hedwig_settings
from hedwig.core.emitter import Emitter
import json

hedwig_emitter = Emitter(hedwig_settings)

# hedwig_emitter.emit('accounts.model.create.1', json.dumps({
#     'id': 1,
#     'username': 'piyush'
# }))
#
# hedwig_emitter.emit('message.serializer.create.asdf123', json.dumps({
#     'mid': "asdf123",
#     'from': 'piyush',
#     'to': 'sandeep',
#     'message': 'ye lo babua chal pada'
# }))

for x in range(1, 10000):
    hedwig_emitter.emit('accounts.model.create.{0}'.format(x), json.dumps({


# Path: tests/settings.py
# USER_SETTINGS = {
#     'VHOST': 'hedwig_server',
#     'USERNAME': 'hedwig_test',
#     'PASSWORD': 'hedwig_pass',
#     'CONSUMER': {
#         'RAISE_EXCEPTION': True,
#         'QUEUES': {
#             'everything_printer': {
#                 'BINDINGS': ['#'],
#                 'CALLBACK': 'tests.callbacks.printer',
#                 'DURABLE': False,
#                 'AUTO_DELETE': True,
#                 'NO_ACK': True
#             },
#             # 'accounts_catch_all': {
#             #     'BINDINGS': ['accounts.#'],
#             #     'CALLBACK': 'tests.callbacks.accounts_printer',
#             #     'DURABLE': False,
#             #     'AUTO_DELETE': True,
#             #     'NO_ACK': True
#             # },
#             # 'message_create': {
#             #     'BINDINGS': ['message.serializer.create.*'],
#             #     'CALLBACK': 'tests.callbacks.message_printer',
#             #     'DURABLE': False,
#             #     'AUTO_DELETE': True,
#             #     'NO_ACK': True
#             # }
#         }
#     }
# }
# 
# Path: hedwig/core/emitter.py
# class Emitter(Base):
#     def emit(self, key, message):
#         """
#          Emits a message to RabbitMQ
# 
#         :param key: Routing key to emit on
#         :param message: json serialized msg body
#         :return:
#         :raises Exception: If RAISE_EXCEPTION is true in emitter settings
#         """
#         try:
#             self._emit(key, message)
#         except ConnectionClosed:
#             self.shutdown()
#             self._emit(key, message)
#         except Exception as e:
#             LOGGER.exception("Emitter exception %s" % str(e))
#             if self.settings.EMITTER['RAISE_EXCEPTION']:
#                 raise
# 
#     def _emit(self, key, message):
#         pub_channel = self.get_channel()
#         LOGGER.debug("Trying to emit - %s" % message)
#         if pub_channel.basic_publish(exchange=self.settings.EXCHANGE, routing_key=key, body=message):
#             LOGGER.info("Emitted - %s" % message)
#         else:
#             LOGGER.error("Failed to emit - %s" % message)


# Path: tests/emitter.py
from .settings import hedwig_settings
from hedwig.core.emitter import Emitter
import json


hedwig_emitter = Emitter(hedwig_settings)

# hedwig_emitter.emit('accounts.model.create.1', json.dumps({
#     'id': 1,
#     'username': 'piyush'
# }))
#
# hedwig_emitter.emit('message.serializer.create.asdf123', json.dumps({
#     'mid': "asdf123",
#     'from': 'piyush',
#     'to': 'sandeep',
#     'message': 'ye lo babua chal pada'
# }))

for x in range(1, 10000):
    hedwig_emitter.emit('accounts.model.create.{0}'.format(x), json.dumps({


        'id': x,