Setting up the publisher to notify the subscriber involves two steps:
- Associating the listener with the topic
- Sending a message to the subscriber
The first step is achieved in the views.py module of the Django maintenance app. In the accept() method, the following is added immediately after variable initialization:
from biglittle.events.publisher import Publisher
publisher = Publisher()
config = Config()
userSvc = UserService(config, 'User', publisher)
loanSvc = LoanService(config, 'Loan', publisher)
publisher.attach(publisher.EVENT_LOAN_UPDATE_BORROWER, \
userSvc.updateBorrowerListener)
In the biglittle.domain.base.Base class, we modify the __init__() method to accept the publisher as an argument:
class Base :
def __init__(self, config, result_class = None, publisher = None) :
self.publisher = publisher
# other logic in this method now shown
In the processPayment() method...