Steps to Implement a Consumer
Essentially a Consumer is a Client in the traditional sense. This can be implemented in many ways and depends on your requirements. Typical ways how to include a consumer in your environment may include:
- Standalone Executable that regularly checks your data store for changes and then request these to be applied by the provider. This is a typical "integration" setup where end-users are not directly involved.
- Part of an other application such as a mobile application, a web-application where an end-user interactively 'triggers/requests' modifications that must be sent to the provider.
In either implementation above the core components that must be considered in implementing a Consumer are:
- Chose the data model you consumer deals with (i.e. SIF AU 1.3)
- What SIF Objects does the consumer deal with?
- Consumer must be able to marshal/unmarshal your data model to/from XML/JSON
- Manage the SIF Environment the consumer operates in.
- Does the consumer subscribe to Events?
- Does the consumer interact in a direct or brokered environment (should not matter for implementation, though)?
- Does consumer deal with delayed responses?
Once the above is decided you should be in a position to start implementing all or at least parts of your consumer.
How do you get hold of a data model and how do you include this in your consumer (or provider)? This is the first thing you will ask yourself. In the past you most likely would have used the OpenADK to take care of this. In SIF3 that has changed. There is no OpenADK! Not yet anyway...
There are several way how you can get the SIF Data Model you need for your consumer:
- Create the model object yourself. This can be a lot of work, or you only implement the SIF objects you need for your consumer.
- Use the SIF Specification's XSD that defines the data model and use some sort of generator to create the data model classes for you based on the XSD.
- Maybe a 3rd Party has a library that provides you with the classes for the data model you require.
Whatever method you use, you will require functionality that marshals your data model classes into XML/JSON or unmarshals XML/JSON back to your data model classes.
A consumer will connect to an environment to retrieve the services it has access to. The first step in your consumer implementation are the ones that deal with authentication and authorisation to a valid SIF environment. Only when you are properly authenticated in an environment you can start requesting data in that environment.
If your consumer wants to deal with Events it must further provision itself. As part of the provisioning process it will tell the provider what queues to use to send events on. It can also tell the provider on what queues it wants to receive delayed responses (asynchronous behaviour). Events and Delayed Responses are outside the scope of this workshop but are definitely part of SIF3.
If you use the SIF3 Farmework (Java only as of May 2014) all of the above is taken care of. You can implement a consumer almost immediately, assuming you use a data model that has the marshal/unmarshal functionality supported. In the SIF3 Framework from GitHub there is such a data model for SIF AU 1.3. Use the Developer's Guide that details what steps, classes, configurations you need to implement or consider to get a consumer implemented.