Skip to content
Snippets Groups Projects
Commit 0d14546f authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8887: use proper default notification busname, prefix, subject

parent 606709c7
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
# $Id$
DEFAULT_BUSNAME = 'lofar.ra.notification'
DEFAULT_NOTIFICATION_SUBJECT_PREFIX = 'RADB.'
DEFAULT_NOTIFICATION_BUSNAME = 'lofar.ra.notification'
DEFAULT_NOTIFICATION_PREFIX = 'RADB.'
DEFAULT_NOTIFICATION_SUBJECTS=DEFAULT_NOTIFICATION_PREFIX+'*'
......@@ -28,7 +28,7 @@ Typical usage is to derive your own subclass from RADBBusListener and implement
"""
from lofar.messaging.messagebus import AbstractBusListener
from lofar.sas.resourceassignment.database.config import DEFAULT_BUSNAME
from lofar.sas.resourceassignment.database.config import DEFAULT_NOTIFICATION_BUSNAME, DEFAULT_NOTIFICATION_SUBJECTS
from lofar.common.util import waitForInterrupt
import qpid.messaging
......@@ -39,7 +39,7 @@ logger = logging.getLogger(__name__)
class RADBBusListener(AbstractBusListener):
def __init__(self, busname=DEFAULT_BUSNAME, subject='RADB.*', broker=None, **kwargs):
def __init__(self, busname=DEFAULT_NOTIFICATION_BUSNAME, subject=DEFAULT_NOTIFICATION_SUBJECTS, broker=None, **kwargs):
"""
RADBBusListener listens on the lofar notification message bus and calls (empty) on<SomeMessage> methods when such a message is received.
Typical usage is to derive your own subclass from RADBBusListener and implement the specific on<SomeMessage> methods that you are interested in.
......
......@@ -32,15 +32,15 @@ from optparse import OptionParser
from lofar.common.postgres import PostgresListener, makePostgresNotificationQueries
from lofar.messaging import EventMessage, ToBus
from lofar.sas.resourceassignment.database.config import DEFAULT_BUSNAME, DEFAULT_NOTIFICATION_SUBJECT_PREFIX
from lofar.sas.resourceassignment.database.config import DEFAULT_NOTIFICATION_BUSNAME, DEFAULT_NOTIFICATION_PREFIX
from lofar.common import dbcredentials
logger = logging.getLogger(__name__)
class RADBPGListener(PostgresListener):
def __init__(self,
busname=DEFAULT_BUSNAME,
notification_prefix=DEFAULT_NOTIFICATION_SUBJECT_PREFIX,
busname=DEFAULT_NOTIFICATION_BUSNAME,
notification_prefix=DEFAULT_NOTIFICATION_PREFIX,
dbcreds=None,
broker=None):
super(RADBPGListener, self).__init__(dbcreds.host, dbcreds.database, dbcreds.user, dbcreds.password)
......@@ -140,8 +140,8 @@ def main():
parser = OptionParser("%prog [options]",
description='runs the radb postgres listener which listens to changes on some tables in the radb and publishes the changes as notifications on the bus.')
parser.add_option('-q', '--broker', dest='broker', type='string', default=None, help='Address of the qpid broker, default: localhost')
parser.add_option("-b", "--busname", dest="busname", type="string", default=DEFAULT_BUSNAME, help="Name of the publication bus on the qpid broker, [default: %default]")
parser.add_option("-n", "--notification_prefix", dest="notification_prefix", type="string", default=DEFAULT_NOTIFICATION_SUBJECT_PREFIX, help="The prefix for all notifications of this publisher, [default: %default]")
parser.add_option("-b", "--busname", dest="busname", type="string", default=DEFAULT_NOTIFICATION_BUSNAME, help="Name of the publication bus on the qpid broker, [default: %default]")
parser.add_option("-n", "--notification_prefix", dest="notification_prefix", type="string", default=DEFAULT_NOTIFICATION_PREFIX, help="The prefix for all notifications of this publisher, [default: %default]")
parser.add_option_group(dbcredentials.options_group(parser))
parser.set_defaults(dbcredentials="RADB")
(options, args) = parser.parse_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment