FeaturesThe Validation Service-Engine allows to validate and filter Petals messages against an XML Schema. Each configuration of this component embeds an XML Schema (made up of one or several XSD files). This component only acts as service provider, not as a service consumer. Validation Component overview
Recommended usage
A typical exampleOne typical example would be a service converting the received message as data and manipulating it then (e.g. to insert it into a database). Another example could be a service that accesses an EJB. In a perfect SOA world, this component would be useless. It can be the case with integration use cases (e.g. with an EIP - Enterprise Integration Pattern - or a POJO that consumes a service by generating dynamically the message to send). Roughly, the principle looks like if( validationService.validate( MSG )) { criticalService.criticalOperation( MSG ); } else { log( "The message was invalid." ); } Validation and chaining servicesFollowing our previous algorithm, it appears that validating or filtering a message only makes sense if this message is going to be sent to another service.
This chaining service can be implemented by a POJO (an home made Java Class) or an Enterprise Integration Pattern (EIP). Limitations
Neither to validate attached, nor to intercept and validate messages on the fly. |
Table of contents
Contributors
No contributors found for: authors on selected page(s)
|
Creating a XML Validation service (Provides mode)
Each Validation service runs on the Petals Validation component.
The Petals Validation component has native operations to invoke. These operations are inherited by the Validation services.
A Validation service cannot add additional operations. It only has the ones of the XSLT component.
The version 1.1 of the Petals Validation component exposes two operations.
- validate: the received message is validated against a XML-Schema. The service returns a boolean response indicating if the message is valid.
- filter: the received message is validated against a XML-Schema. If the message is valid, this same message is returned. Otherwise, a fault is raised.
The "validate" operation
The fully qualified name of this operation is:
- Name space URI: *http://petals.ow2.org/components/validation/version-1*
- Local part: validate
This operation only supports the InOut message exchange pattern (MEP).
When invoking this operation, you must call it using its fully qualified name.
Here is the execution flow for this operation:
- The received message is validated against the XML-Schema embedded by the service.
- The validation response is wrapped into a message and sent back.
More precisely, if the message is valid, the returned message is
<!-- The target name space depends on the version of the Validation component --> <tns:validateResponse xmlns:tns='http://petals.ow2.org/components/validation/version-1'> <tns:valid>true</tns:valid> </tns:validateResponse>
Otherwise, it is
<!-- The target name space depends on the version of the Validation component --> <tns:validateResponse xmlns:tns='http://petals.ow2.org/components/validation/version-1'> <tns:valid>false</tns:valid> <tns:comment>The reason explaining why it is invalid.</tns:comment> </tns:validateResponse>
The "filter" operation
The fully qualified name of this operation is:
- Name space URI: *http://petals.ow2.org/components/validation/version-1*
- Local part: filter
This operation only supports the InOut message exchange pattern (MEP).
When invoking this operation, you must call it using its fully qualified name.
Here is the execution flow for this operation:
- The received message is validated against the XML-Schema embedded by the service.
- If the message is valid, this same message is sent back. Otherwise, a fault is raised.
<!-- The target name space depends on the version of the Validation component --> <tns:validationFault xmlns:tns='http://petals.ow2.org/components/validation/version-1'> <tns:message>The fault message.</tns:message> <tns:validationFault>
If the operation is invalid (i.e. is neither validate, nor filter), then filter is the operation by default. |
WSDL definitions
By default, services deployed on the Validation component do not need a WSDL.
However, as a good practice, it is better to provide it one.
The operations are known.
The only unknown is whether the input messages will be anyType or the exact top element of the XML Schema.
It is let to the choice of the user.
The output message for the operation filter should however be described by the XML Schema.
JBI descriptor
The Service Unit descriptor file ( jbi.xml ) looks like this:
<?xml version="1.0" encoding="UTF-8"?> <jbi:jbi version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jbi="http://java.sun.com/xml/ns/jbi" xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5" xmlns:validation="http://petals.ow2.org/components/validation/version-1" xmlns:serviceNs="http://petals.ow2.org/simpletransformation"> <jbi:services binding-component="false"> <jbi:provides interface-name="serviceNs:ValidationInterface" service-name="serviceNs:ValidationService" endpoint-name="ValidationEndpoint"> <!-- WSDL file --> <petalsCDK:wsdl>your optional description wsdl file.wsdl</petalsCDK:wsdl> <!-- Validation specific fields --> <validation:schema>schema.xsd</validation:schema> </jbi:provides> </jbi:services> </jbi:jbi>
A JBI descriptor for an Validation service-unit can only define one provides block.
Parameter | Description |
Default |
Required |
---|---|---|---|
provides | Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. | - | Yes |
Parameter | Description | Default | Required |
---|---|---|---|
schema | Location of the XSD schema. This path must be a relative path from the root of the SU package. | -
|
Yes
|
Interceptor
Example of an interceptor configuration:
<?xml version="1.0" encoding="UTF-8"?> <!--...--> <petalsCDK:su-interceptors> <petalsCDK:send> <petalsCDK:interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> <petalsCDK:param name="myParamName2">myParamValue2</petalsCDK:param> </petalsCDK:interceptor> </petalsCDK:send> <petalsCDK:accept> <petalsCDK:interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:interceptor> </petalsCDK:accept> <petalsCDK:send-response> <petalsCDK:Interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:Interceptor> </petalsCDK:send-response> <petalsCDK:accept-response> <petalsCDK:Interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:Interceptor> </petalsCDK:accept-response> </petalsCDK:su-interceptors> <!--...-->
Interceptors configuration for SU (CDK)
Parameter | Description | Default | Required |
---|---|---|---|
send | Interceptor dedicated to send phase, for an exchange sent by a consumer | - | No |
accept | Interceptor dedicated to receive phase, for an exchange received by a provider | - | No |
send-response | Interceptor dedicated to send phase, for an exchange (a response) received by a consumer | - | No |
accept-response | Interceptor dedicated to receive phase, for an exchange sent (a response) by a provider | - | No |
interceptor - name | Logical name of the interceptor instance. It can be referenced to add extended parameters by a SU Interceptor configuration. | - | Yes |
param[] - name | The name of the parameter to use for the interceptor for this SU | - | No |
param[] | The value of the parameter to use for the interceptor for this SU | - | No |
Service-Unit content
The service unit must contain the XML Schema and the JBI descriptor (jbi.xml file).
It is also highly recommended to provide a WSDL description for this service (though it is optional).
This WSDL is not mandatory, but not providing it will prevent your service from interacting with other Petals services and components.
The directory structure of a SU for the Petals-SE-Validation looks like this:
su-xslt-TransformationName-provide.zip + META-INF - jbi.xml + XsltService.wsdl (recommended) + myfile.xsd (required) + myfile2.xsd (required if myfile2.xsd is imported in myfile.xsd)
Configuring the component
The component can be configured through its JBI descriptor file, as shown below.
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?> <jbi version="1.0" xmlns='http://java.sun.com/xml/ns/jbi' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"> <component type="service-engine"> <identification> <name>petals-se-validation</name> <description>A VALIDATION Service Engine</description> </identification> <component-class-name description="Validation Component class">org.ow2.petals.se.validation.ValidationComponent</component-class-name> <component-class-path><path-element/></component-class-path> <bootstrap-class-name>org.ow2.petals.component.framework.DefaultBootstrap</bootstrap-class-name> <bootstrap-class-path><path-element/></bootstrap-class-path> <petalsCDK:acceptor-pool-size>3</petalsCDK:acceptor-pool-size> <petalsCDK:processor-pool-size>10</petalsCDK:processor-pool-size> <petalsCDK:ignored-status>DONE_AND_ERROR_IGNORED</petalsCDK:ignored-status> <petalsCDK:notifications>false</petalsCDK:notifications> <petalsCDK:jbi-listener-class-name>org.ow2.petals.se.validation.listener.JBIListener</petalsCDK:jbi-listener-class-name> </component> </jbi>
The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.
Parameter | Description | Default | Required | Scope |
---|---|---|---|---|
acceptor-pool-size | The size of the thread pool used to accept Message Exchanges from the NMR. Once a message is accepted, its processing is delegated to the processor pool thread. | 3
|
Yes
|
Runtime
|
acceptor-retry-number | Number of tries to submit a message exchange to a processor for processing before to declare that it cannot be processed. | 40
|
No
|
Installation
|
acceptor-retry-wait | Base duration, in milliseconds, to wait between two processing submission tries. At each try, the new duration is the previous one added by this base duration multiplied by the try number plus a random value between 0 and 10. | 250
|
No
|
Installation
|
acceptor-stop-max-wait | The max duration (in milliseconds) of the stop of an acceptor before to force it to stop. | 500
|
No
|
Runtime
|
message-processor-max-pool-size | Max size of the object pool containing message exchange processors. | processor-max-pool-size
|
No
|
Runtime
|
processor-pool-size | The size of the thread pool used to process Message Exchanges. Once a message is accepted, its processing is delegated to one of the thread of this pool. | 10
|
Yes
|
Runtime
|
processor-max-pool-size | The maximum size of the thread pool used to process Message Exchanges. The difference between this size and the processor-pool-size represents the dynamic threads that can be created and destroyed during overhead processing time. |
50
|
No
|
Runtime
|
processor-keep-alive-time | When the number of processors is greater than the core, this is the maximum time that excess idle processors will wait for new tasks before terminating, in seconds. |
300
|
No
|
Runtime
|
processor-stop-max-wait | The max duration (in milliseconds) of message exchange processing on stop phase. |
15000
|
No
|
Runtime
|
time-beetween-async-cleaner-runs | The time (in milliseconds) between two runs of the asynchronous message exchange cleaner. |
2000
|
No
|
Installation
|
properties-file | Name of the file containing properties used as reference by other parameters. Parameters reference the property name in the following pattern ${myPropertyName}. At runtime, the expression is replaced by the value of the property. The properties file can be reloaded using the JMX API of the component. The runtime configuration MBean provides an operation to reload these place holders. Check the service unit parameters that support this reloading. The value of this parameter is :
|
-
|
No
|
Installation
|
monitoring-sampling-period | Period, in seconds, of a sample used by response time probes of the monitoring feature. |
300
|
No
|
Installation
|
Definition of CDK parameter scope :
- Installation: The parameter can be set during the installation of the component, by using the installation MBean (see JBI specifications for details about the installation sequence). If the parameter is optional and has not been defined during the development of the component, it is not available at installation time.
- Runtime: The paramater can be set during the installation of the component and during runtime. The runtime configuration can be changed using the CDK custom MBean named RuntimeConfiguration. If the parameter is optional and has not been defined during the development of the component, it is not available at installation and runtime times.
Interceptor
Interceptors can be defined to inject some post or pre processing in the component during service processing.
Using interceptor is very sensitive and must be manipulate only by power users. An non properly coded interceptor engaged in a component can lead to uncontrolled behaviors, out of the standard process.
Example of an interceptor configuration:
<?xml version="1.0" encoding="UTF-8"?> <!--...--> <petalsCDK:component-interceptors> <petalsCDK:interceptor active="true" class="org.ow2.petals.myInterceptor" name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> <petalsCDK:param name="myParamName2">myParamValue2</petalsCDK:param> </petalsCDK:interceptor> </petalsCDK:component-interceptors> <!--...-->
Interceptors configuration for Component (CDK)
Parameter | Description | Default | Required |
---|---|---|---|
interceptor - class | Name of the interceptor class to implement. This class must extend the abstract class org.ow2.petals.component.common.interceptor.Interceptor. This class must be loadable from the component classloader, or in a dependent Shared Library classloader. | - | Yes |
interceptor - name | Logical name of the interceptor instance. It can be referenced to add extended parameters by a SU Interceptor configuration. | - | Yes |
interceptor - active | If true, the Interceptor instance is activated for every SU deployed on the component. If false, the Interceptor can be activated: -by the InterceptorManager Mbean at runtime, to activate the interceptor for every deployed SU. -by a SU configuration |
- | Yes |
param[] - name | The name of the parameter to use for the interceptor. | - | No |
param[] | The value of the parameter to use for the interceptor. | - | No |
This component does not have any specific configuration parameter.
Monitoring the component
In this documentation, the term "Allocated threads" must be understood as "Active threads", see PETALSDISTRIB-37. This naming error will be fixed in the next version. |
Using metrics
Several probes providing metrics are included in the component, and are available through the JMX MBean 'org.ow2.petals:type=custom,name=monitoring_<component-id>', where <component-id> is the unique JBI identifier of the component.
Common metrics
The following metrics are provided through the Petals CDK, and are common to all components:
Metrics, as MBean attribute | Description | Detail of the value | Configurable |
---|---|---|---|
MessageExchangeAcceptorThreadPoolMaxSize | The maximum number of threads of the message exchange acceptor thread pool | integer value, since the last startup of the component | yes, through acceptor-pool-size |
MessageExchangeAcceptorThreadPoolCurrentSize | The current number of threads of the message exchange acceptor thread pool. Should be always equals to MessageExchangeAcceptorThreadPoolMaxSize. | instant integer value | no |
MessageExchangeAcceptorCurrentWorking | The current number of working message exchange acceptors. | instant long value | no |
MessageExchangeAcceptorMaxWorking | The max number of working message exchange acceptors. | long value, since the last startup of the component | no |
MessageExchangeAcceptorAbsoluteDurations | The aggregated durations of the working message exchange acceptors since the last startup of the component. | n-tuple value containing, in nanosecond:
|
no |
MessageExchangeAcceptorRelativeDurations | The aggregated durations of the working message exchange acceptors on the last sample. | n-tuple value containing, in nanosecond:
|
no |
MessageExchangeProcessorObjectPoolBorrowedObjectsCurrent | The current number of borrowed object of the message exchange processor object pool | instant integer value | no |
MessageExchangeProcessorObjectPoolBorrowedObjectsMax | The maximum number of object of the message exchange processor object pool that was borrowed | integer value, since the last startup of the component | no |
MessageExchangeProcessorObjectPoolIdleObjectsCurrent | The current number of idel object of the message exchange processor object pool | instant integer value | no |
MessageExchangeProcessorObjectPoolIdleObjectsMax | The maximum number of object of the message exchange processor object pool that was idle | integer value, since the last startup of the component | no |
MessageExchangeProcessorObjectPoolMaxSize | The maximum size, in objects, of the message exchange processor object pool | instant integer value | yes, through processor-max-pool-size |
MessageExchangeProcessorObjectPoolMinIdleSize | The minimum size, in objects (in state idle), of the message exchange processor object pool | instant integer value | yes, through processor-pool-size |
MessageExchangeProcessorObjectPoolExhaustion | The number of message exchange processor object pool exhaustions | integer counter value, since the last startup of the component | no |
MessageExchangeProcessorThreadPoolAllocatedThreadsCurrent | The current number of allocated threads of the message exchange processor thread pool | instant integer value | no |
MessageExchangeProcessorThreadPoolAllocatedThreadsMax | The maximum number of threads of the message exchange processor thread pool that was allocated | integer value, since the last startup of the component | no |
MessageExchangeProcessorThreadPoolIdleThreadsCurrent | The current number of idle threads of the message exchange processor thread pool | instant integer value | no |
MessageExchangeProcessorThreadPoolIdleThreadsMax | The maximum number of threads of the message exchange processor thread pool that was idle | integer value, since the last startup of the component | no |
MessageExchangeProcessorThreadPoolMaxSize | The maximum size, in threads, of the message exchange processor thread pool | instant integer value | yes, through http-thread-pool-size-max |
MessageExchangeProcessorThreadPoolMinSize | The minimum size, in threads, of the message exchange processor thread pool | instant integer value | yes, through http-thread-pool-size-min |
MessageExchangeProcessorThreadPoolQueuedRequestsCurrent | The current number of enqueued requests waiting to be processed by the message exchange processor thread pool | instant integer value | no |
MessageExchangeProcessorThreadPoolQueuedRequestsMax | The maximum number of enqueued requests waiting to be processed by the message exchange processor thread pool that was allocated since the last startup of the component | instant integer value | no |
ServiceProviderInvokations | The number of service provider invokations grouped by:
|
integer counter value since the last startup of the component | no |
ServiceProviderInvokationsResponseTimeAbs | The aggregated response times of the service provider invokations since the last startup of the component grouped by:
|
n-tuple value containing, in millisecond:
|
no |
ServiceProviderInvokationsResponseTimeRel | The aggregated response times of the service provider invokations on the last sample, grouped by:
|
n-tuple value containing, in millisecond:
|
no |
Dedicated metrics
No dedicated metric is available.
Receiving alerts
Several alerts are notified by the component through notification of the JMX MBean 'org.ow2.petals:type=custom,name=monitoring_<component-id>', where <component-id> is the unique JBI identifier of the component.
To integrate these alerts with Nagios, see Receiving Petals ESB defects in Nagios. |
Common alerts
Defect | JMX Notification |
---|---|
A message exchange acceptor thread is dead |
|
No more thread is available in the message exchange acceptor thread pool |
|
No more message exchange processor is available in the message exchange processor pool |
|
No more thread is available to run a message exchange processor |
|
Dedicated alerts
No dedicated alert is available.