Skip to content

danhaywood/camel-isis-pubsubjdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camel Subscriber for Isis' PublishingService

An Apache Camel-based subscriber of events published by the Apache Isis JDO Objectstore's implementation of Isis' own PublishingService API.

Objective

The Isis PublishingServiceJdo implementation persisted events into a PUBLISHEDEVENT database table, with the payload of the event serialized into JSON as per the RestfulObjectsSpecEventSerializer.

This project defines a Camel-based subscriber that polls this database table for events, unmarshals them into an object representation of the serialized JSON, and then routes these events to an Apache CXF-based web service.

The different responsibilities have been factored out into separate modules, so if you fork this code, you should be able to reuse a good deal of this code.

Design

There are five modules that make up this project. Four constitute production code, one is intended for testing):

  • bus

    This defines some very simple classes that convert the published event PublishedEventSerializedFormRepr and its headers) into a canonical format for other consumers. It defines two such classes - ActionInvocationPayloadRepr and ObjectChangedPayloadRepr, - are subclasses of the DomainObjectRepresentation provided by the Restful Objects viewers' applib; basically just wrappers around the JSON format. Subscribers can easily reach into these JSON structures to inspect the data that they require.

    ActionInvocationPayloadRepr corresponds to events whose event type is ACTION_INVOCATION, while ObjectChangedPayloadRepr corresponds to events whose event type is any of OBJECT_CREATED, OBJECT_UPDATED or OBJECT_DELETED.

  • publisher

    This module defines a class to act as a JPA endpoint acting as a producer (ie polling for events from the SQL Server PUBLISHEDEVENT table). The JPA entity is also called PublishedEvent.

    The module also provides IsisPubSubCanonicalizer - a Camel processor that converts the PublishedEvent into an message on the Camel pipeline whose headers correspond to the properties of the PublishedEvent. The body is an instance of either ActionInvocationPayloadRepr or ObjectChangedPayloadRepr (as defined by the bus module), corresponding to the JSON taken from the PublishedEvent's serializedForm property.

  • soapsubscriber

    This module has a very simple WSDL and is configured to use an CXF Maven plugin for generating the interface definitions and client-side.

    The WSDL simply accepts a single string (intended to be the identifier of a ToDoItem that has been 'completed'); because the module is generated from the WSDL, it should be straight-forward enough to replace with the WSDL of some other web service.

    The module also defines a bean to extract (transform) the appropriate information from the canonical bus representation to call the web service.

  • soapsubscriberstub

    This module is for testing only, and provides a simple implementation of the webservice which can be started/stopped from tests and provides a backdoor 'spy' method to check if and how it has been called.

  • webconsole

    This module has dependencies on the bus, publisher and soapsubscriber modules, and contains the Camel route to take published events from JPA and selectively send them to the web service.

    The tests in this module also depend upon the soapsubscriberstub module, checking that the web service was called correctly.

The Camel route can be found in webconsole/src/main/webapp/WEB-INF/applicationContext.xml (in the <camelContext> element).

Diagram

All the above as a pretty picture:

Running

To run the soapsubscriberstub, just use

  cd soapsubscriberstub
  mvn -P server

You can test this service independently using the org.apache.isis.example.wrj.todoitem.ToDoItemClient class in soapsubscriber module.

To run the webconsole, just use

  cd webconsole
  mvn clean package jetty:run

Note that this cannot (easily) be run from the IDE because of the OpenJPA enhancement process that is required.

If you run up Isis with the ToDo quickstart app, then any ACTION_INVOCATION events (eg invoking the complete() action on a ToDoItem) should be routed through the webservice (and the href of the target of the event will appear in the console of the soapsubscriberstub) whereas any OBJECT_CREATED, OBJECT_UPDATED or OBJECT_DELETED events will be printed to the console of the webconsole.

About

An Apache Camel-based subscriber of events published by the Apache Isis JDO Objectstore's implementation of Isis' own PublishingService API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages