# Override broadcast\_identifier

**URL:** <https://discourse.nameko.io/t/override-broadcast-identifier/131>\
**Category:** googlegroup\
**Created:** [May 12, 2016, 7:02pm UTC](https://discourse.nameko.io/t/override-broadcast-identifier/131 "2016-05-12T19:02:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conor\_Seabrook](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/conor_seabrook/32/85_2.png) [@Conor\_Seabrook](https://discourse.nameko.io/u/Conor_Seabrook)\
**Post date:** [May 12, 2016, 7:02pm UTC](https://discourse.nameko.io/t/override-broadcast-identifier/131/1 "2016-05-12T19:02:34Z")

</div>

Hello,

I just upgraded to 2.3.1 and need to override the broadcast\_identifier for  
reliable broadcast delivery as we have some broadcasted events which we  
need to be reliable.

Any hints on how to override the broadcast\_identifier? I looked at the code  
and see the property, just clueless on how to actually override it.

Thanks,  
Conor

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [May 12, 2016, 7:23pm UTC](https://discourse.nameko.io/t/override-broadcast-identifier/131/2 "2016-05-12T19:23:31Z")

</div>

Just create a subclass and use that:

# myapp/entrypoints.py

import socket from nameko.events import EventHandler as NamekoEventHandler

class EventHandler(NamekoEventHandler):  
&nbsp;&nbsp;&nbsp;&nbsp;""" EventHandler that uses `socket.gethostname` as its broadcast identifier """

&nbsp;&nbsp;&nbsp;&nbsp;@property  
&nbsp;&nbsp;&nbsp;&nbsp;def broadcast\_identifier(self):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return socket.gethostname()

event\_handler = EventHandler.decorator

# service.py (no different apart from the imports)

from myapp.entrypoints import event\_handler

class MyService(object):  
&nbsp;&nbsp;&nbsp;&nbsp;name = "myservice"

&nbsp;&nbsp;&nbsp;&nbsp;@event\_handler("src\_service", "event\_type", handler\_type=BROADCAST)  
&nbsp;&nbsp;&nbsp;&nbsp;def handle(self, event\_data):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass

Using subclasses is the generally encouraged way to extend nameko, and I  
will update the docs to that effect when I get a chance.

> **···**
>
> On Thursday, May 12, 2016 at 8:02:34 PM UTC+1, Conor Seabrook wrote:
> 
> > Hello,
> > 
> > I just upgraded to 2.3.1 and need to override the broadcast\_identifier for  
> > reliable broadcast delivery as we have some broadcasted events which we  
> > need to be reliable.
> > 
> > Any hints on how to override the broadcast\_identifier? I looked at the  
> > code and see the property, just clueless on how to actually override it.
> > 
> > Thanks,  
> > Conor

---

<div class="post-metadata">

**Author:** ![Conor\_Seabrook](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/conor_seabrook/32/85_2.png) [@Conor\_Seabrook](https://discourse.nameko.io/u/Conor_Seabrook)\
**Post date:** [May 13, 2016, 6:33pm UTC](https://discourse.nameko.io/t/override-broadcast-identifier/131/3 "2016-05-13T18:33:50Z")

</div>

Perfect, thank you sir!

> **···**
>
> On Thursday, May 12, 2016 at 3:23:31 PM UTC-4, Matt Bennett wrote:
> 
> > Just create a subclass and use that:
> > 
> > # myapp/entrypoints.py
> > 
> > import socket from nameko.events import EventHandler as NamekoEventHandler
> > 
> > class EventHandler(NamekoEventHandler):  
> > &nbsp;&nbsp;&nbsp;&nbsp;""" EventHandler that uses `socket.gethostname` as its broadcast identifier """
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@property  
> > &nbsp;&nbsp;&nbsp;&nbsp;def broadcast\_identifier(self):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return socket.gethostname()
> > 
> > event\_handler = EventHandler.decorator
> > 
> > # service.py (no different apart from the imports)
> > 
> > from myapp.entrypoints import event\_handler
> > 
> > class MyService(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = "myservice"
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@event\_handler("src\_service", "event\_type", handler\_type=BROADCAST)  
> > &nbsp;&nbsp;&nbsp;&nbsp;def handle(self, event\_data):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass
> > 
> > Using subclasses is the generally encouraged way to extend nameko, and I  
> > will update the docs to that effect when I get a chance.
> > 
> > On Thursday, May 12, 2016 at 8:02:34 PM UTC+1, Conor Seabrook wrote:
> > 
> > > Hello,
> > > 
> > > I just upgraded to 2.3.1 and need to override the broadcast\_identifier  
> > > for reliable broadcast delivery as we have some broadcasted events which we  
> > > need to be reliable.
> > > 
> > > Any hints on how to override the broadcast\_identifier? I looked at the  
> > > code and see the property, just clueless on how to actually override it.
> > > 
> > > Thanks,  
> > > Conor
