How To Handle Notifications Published To MD-SAL

MD-SAL has handlers written for MD-SAL notification types. One such example is NodeChangeCommiter which handles the notifications published on NodeUpdated notification type – refer here.

Let’s say we have defined a new YANG model and have created a new notification type shapeDone as follows:

On converting this YANG file to Java, following files will get created:

  • ShapeListener – a listener nterface that declares the method onShapeDone
  • ShapeDone – an object of type notification (extends opendaylight Notification interface)
  • ShapeDoneBuilder – builder class to create an instance of type ShapeDone

Let’s say the provider publishes a notification on ShapeDone object as below: [Refer this link for more details]

Consumer should have a handler to handle this notification. First, consumer should implement ShapeListener interface and provide implementation for onShapeDone as below:

Then, it should register this listener to MD-SAL as below. By doing this, we are letting MD-SAL know that “Hey, if you receive a notification of type ShapeDone, you need to notify ShapeListenerImpl.


  1. t-anh says

    Thank you for this tutorial
    I create my project “myapp” from Startup Project Archetype.
    Then define notification in yang file and auto-generate java file from yang.
    When i register for notifications as follow

    NotificationService notificationService = session. getSALService(NotificationService.class);
    listenerReg = notificationService.registerNotificationListener(new MyappListenerImpl());

    When i build project, test org.opendaylight.myapp.impl.MyAppProviderTest failed because NullPointerException at new MyappListenerImpl().
    Anybogy can help me to solve this error?

  2. says

    Saгah was actually not there certainly even though every early
    morning he was actually hoping tɦat this was nothing at all over a negative dream.
    He required ɦer to be alօng with him.

  3. Paolo says

    Hello, I dont know you you can help me, but Im getting org.opendaylight.controller.sal.binding.api.NotificationService is not available when I put my Jar on opendaylight deploy directory. I tried to install metal all but still having this issue and don’t know why.

Leave a Reply

Your email address will not be published. Required fields are marked *