Django integration

pyhermes has built-in Django integration.

To use pyhermes together with Django, follow these steps:

  1. Add pyhermes.apps.django to INSTALLED_APPS in settings.py:
INSTALLED_APPS = (
    # other apps
    'pyhermes.apps.django',
)
  1. Configure pyhermes in settings.py, for example:
HERMES = {
    'BASE_URL': 'http://hermes.local',
    'PUBLISHING_GROUP': {
        'groupName': 'pl.allegro.pyhermes',
        'supportTeam': 'pyLabs',
        'owner': 'pyLabs',
        'contact': 'pylabs@allegro.pl'
    },
    'PUBLISHING_TOPICS': {
        'test1': {
            'description': "test topic",
            'ack': 'LEADER',
            'retentionTime': 1,
            'trackingEnabled': False,
            'contentType': 'JSON',
            'validationEnabled': False,
        }
    }
}
  1. Include pyhermes.apps.django.urls in your urls.py:
urlpatterns += patterns('',
    url(r'^hermes/', include('pyhermes.apps.django.urls')),
)

Use <YOUR-APP-URL>/hermes/events/<TOPIC-NAME> (for example http://my-django-app.local/hermes/events/pl.allegro.pyhermes.test1) to subscribe to particular topic in Hermes.

Test command

After instalation you can test your configuration by following command:

./manage.py hermes_test

Command send message to all topics defined in settings to Hermes.