[sakai2-tcc] messageservice update with event publishing

John Bush john.bush at rsmart.com
Thu May 17 14:23:35 PDT 2012


I've updated the messageservice contrib tool with the following
changes.  Many thanks to Early Nietzel's work on this which was
partially fueled by OAAI grant,
https://confluence.sakaiproject.org/pages/viewpage.action?pageId=75671025

1.  Brought activemq up to version 5.4.0
2.  Added an event publisher.  Which broadcasts sakai events onto a jms queue.

What this means is you can attach listens which picks up events to do
interesting things like warehousing, monitoring, integration, cache
invalidation, etc.  We are using this right now to pick off cm
messages to create sis in response to cm events and to perform
gradebook exports.  It means you can write glue code outside of the
Sakai or use a ESB to do interesting and useful things.  I will doing
a presentation at the conference with more details on this.  The are a
lot of possibilities.  The event itself has a json payload.   The
sakai data, event type, reference extra, are also propagated right in
the JMS headers in most cases you might not even need to look at the
payload. For example:

                message.setStringProperty("server", server);
                message.setJMSType(event.getEvent());
                message.setJMSTimestamp(event.getEventTime().getTime());
                message.setJMSCorrelationID(event.getResource());
                message.setStringProperty("context", event.getContext());
                message.setBooleanProperty("modify", event.getModify());

The active mq console is a nice tool to connect with to let you see
the msgs, purge them, manage them etc.  I'd recommend using that if
you are going to start taking advantage of this infrastructure.

to enable set the following:

sakai.event.publish.jms=true

If you want to broadcast all events do this:

sakai.event.publish.jms.allowedEvents.count=1
sakai.event.publish.jms.allowedEvents.1=*

If you want to send only certain events do this (support regex strings):

sakai.event.publish.jms.allowedEvents.count=2
sakai.event.publish.jms.allowedEvents.1=user.*
sakai.event.publish.jms.allowedEvents.1=pres.*

The default queue is named "events"

# you can override like this
queue at org.sakaiproject.messageservice.jms.activemq.EventPublisher=sakai.events

Adjust the broker properties like this (see components.xml for more options)

scheme at org.sakaiproject.messageservice.api.BrokerUriFactoryBean=nio
port@@org.sakaiproject.messageservice.api.BrokerUriFactoryBean=123123

Adjust the client connection factory like this:

brokerURL at org.sakaiproject.messageservice.JmsConnectionFactory.target=nio://localhost:61616?wireFormat.maxInactivityDuration=0

Example of json payload:

{
    "site": {
        "id": "6e48cab6-7f3c-4a57-afbb-8fd3e6b85ab9",
        "title": "ENGL_101_002_12S",
        "created": 1334681037000,
        "description": " ",
        "properties": {
            "term_eid": "12S",
            "contact-name": "Sakai Administrator",
            "sections_student_registration_allowed": "false",
            "term": "Spring 2012",
            "sections_student_switching_allowed": "false",
            "sections_externally_maintained": "true",
            "site-request-course-sections": "ENGL_101_002_12S"
        },
        "shortdescription": null,
        "published": true,
        "type": "course",
        "reference": "/site/6e48cab6-7f3c-4a57-afbb-8fd3e6b85ab9",
        "url": "http://localhost:8080/xsl-portal/site/6e48cab6-7f3c-4a57-afbb-8fd3e6b85ab9",
        "skin": null,
        "modified": 1336666324000
    },
    "time": 1336666324884,
    "session": {
        "id": "3adf3bff-afcd-40e1-946b-f5547647dcb5",
        "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168
Safari/535.19",
        "start": 1336666282000,
        "browser": "Mac-Mozilla",
        "hostname": null,
        "ipaddress": "0:0:0:0:0:0:0:1%0",
        "end": 1336666282000
    },
    "priority": 2,
    "event": "site.upd",
    "resource": "/site/6e48cab6-7f3c-4a57-afbb-8fd3e6b85ab9",
    "modify": true,
    "server": "localhost",
    "user": {
        "id": "admin",
        "last": "Administrator",
        "created": 1334358879000,
        "email": "",
        "properties": {},
        "type": "",
        "first": "Sakai",
        "eid": "admin",
        "url": "http://localhost:8080/access/useradmin",
        "modified": 1334358879000,
        "displayname": "Sakai Administrator"
    }
}


-- 
John Bush
602-490-0470


More information about the sakai2-tcc mailing list