Django integration¶
pyhermes has built-in Django integration.
To use pyhermes together with Django, follow these steps:
- Add
pyhermes.apps.djangotoINSTALLED_APPSinsettings.py:
INSTALLED_APPS = (
# other apps
'pyhermes.apps.django',
)
- Configure
pyhermesinsettings.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,
}
}
}
- Include
pyhermes.apps.django.urlsin yoururls.py:
urlpatterns += patterns('',
url(r'^hermes/', include('pyhermes.apps.django.urls')),
)
Use
<YOUR-APP-URL>/hermes/events/<TOPIC-NAME>(for examplehttp://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.