FeatureThe REST component is a Binding Component (BC) which enables to interact with external RESTful Web Services and to expose JBI services as RESTful Web Services. In provider role, when a JBI MessageExchange is sent to a ServiceEndpoint (mapped to a Web Service), it is transformed into a REST message and sent to the linked external Web Service. In consumer role, when a REST message is received on an exposed Web Service, it is transformed into a JBI MessageExchange and sent to the corresponding JBI ServiceEndpoint. The REST component is based on Jersey and Axis2 (TBD). It provides the following features:
|
Table of contents Contributors
No contributors found for: authors on selected page(s)
|
Exposing an external Restful Web Service as a JBI service endpoint
In provide mode, the component exposes an external Web Service in the JBI environment to send REST requests to the external Web Service.
Usage
The petals-bc-rest component can expose an external Web Service as a JBI service endpoint by deploying a Service Unit on it:
Provides an external Web Service as a JBI service
When a message is received on a REST linked endpoint from the JBI environment, it is transformed into a REST message and sent to the Web Service.
The REST request is created like this:
- The REST URI is created from the address extension, the JBI operation and JBI message content (The JBI message content must contains the information about the path, the matrix and query parameters)
- The HTTP body is created differently according the HTTP method to used:
- GET/DELETE: There is no HTTP body
- POST: The HTTP body is also created differently according the JBI message content:
- The JBI message content contains only a reference to a JBI attachment: The HTTP body is created from a JBI attachment (binary data)
- The JBI message content does not contains a reference to a JBI attachment: The HTTP body is created from the JBI message content (form parameters)
- PUT: The HTTP body is created from a JBI attachment
- The headers present in the protocol header JBI message property are added to the HTTP headers.
For example the following JBI message:
produces the URI http://weather.yahooapis.com/....
The external Web Service is called and the REST response is processed and returned to the JBI environment.
The REST response is transformed into a JBI message like this:
- In case of error (HTTP status different from 20x) a JBI fault is created.
- The JBI message content and attachment are created differently according the Content-Type HTTP header:
- Non XML content types: The JBI message content is a reference (cf SOAP) to a JBI attachment which contains the HTTP body
- XML content types: The JBI message content is created from the HTTP body (there is no JBI attachment created)
- The HTTP headers are added to the protocol header JBI message property
With no description of the RESTful Web Service
The address of the RESTful Web Service is defined in the address extension of the deployed Service Unit.
The HTTP method is defined in the http-method SU extension.
With a WADL
The address of the RESTful Web Service is found in the WADL.
The REST operation corresponding to the JBI operation is found in the WADL.
The HTTP method is defined in the WADL for the operation.
With a WSDL 2.0
The address of the RESTful Web Service is found in the WSDL 2.0.
The REST operation corresponding to the JBI operation is found in the WSDL 2.0.
The HTTP method is defined in the WSDL 2.0 for the operation.
Configuration
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 |
Attribute | Description | Default value | Required |
---|---|---|---|
address | Address of the external Web Service to send JBI messages to. | Yes*
|
|
http-method | HTTP method to use. Possible values are: GET for the HTTP method GET, POST for the HTTP method POST, PUT for the HTTP method PUT and DELETE for the HTTP method DELETE. |
Yes*
|
|
wadl | WADL which defines the partner service | Yes*
|
|
wsdl2 | WSDL2 which defines the partner service | Yes*
|
*Either address and http-method extensions or wadl or wsdl2 must be present in a specific SU.
Service Unit descriptor
The service unit is configurable via its extensions in the jbi.xml file:
Service Unit content
The Service Unit has to contain the following elements, packaged in an archive:
- The META-INF/jbi.xml descriptor file as described above,
- An optional imported WADL/WSDL 2.0 file describing the partner service
Exposing an internal JBI service endpoint as a RESTful Web Service
In consumer mode, the component exposes an internal JBI service outside the bus to transfer incoming REST requests to the internal service.
Usage
The petals-bc-rest component can listen incoming REST messages and send messages to a JBI service endpoint by deploying a Service Unit on it. The component consumes the JBI service:
Consumes a JBI service on a REST message
The service-name Service Unit extension value will be used as service name.
When a REST message is handled by the component, it is transformed into a JBI Message and sent to the JBI service endpoint configured in the Service Unit.
The JBI message is created like this:
- The JBI operation is created differently from the operation present in the REST URI operation
- The JBI message content is created according to the HTTP method of the incoming REST request:
- GET: The JBI message content is created from the REST URI path and parameters
- POST: The JBI message content is also created differently according the Content-Type HTTP header:
- Non XML content types: The JBI message content is a reference (cf SOAP) to a JBI attachment which contains the HTTP body
- XML content types: The JBI message content is created from the HTTP body (there is no JBI attachment created)
- PUT/DELETE: There is no JBI message content
- A JBI attachment is created according to the HTTP method of the incoming REST request:
- GET/DELETE: There is no JBI attachment created
- POST: A JBI attachment is created from the HTTP body if the Content-Type HTTP header contains a non XML content type.
- PUT: A JBI attachment is created from the HTTP body
- The HTTP headers are added to the the protocol header JBI message property
- The MEP is defined by the petalsCDK:mep extension.
A WADL is available at the following URL: (TBC)
A WSDL 2.0 is available at the following URL: (TBC)
Configuration
Parameter | Description | Default | Required |
---|---|---|---|
consumes | Refer JBI service to invoke into the JBI bus. You can define an explicit endpoint: interface (QName) / Service (QName) / Endpoint (String) attributes. Or define implicit endpoint, to let the container routing according to QOS configurations (HA...): -by Interface attribute (QName) -by Service attribute (QName) |
- | Yes |
Parameter | Description | Default | Required |
---|---|---|---|
mep | Message exchange pattern abbreviation. This parameter can be used in conjunction with the method of the CDK Listeners: createMessageExchange(Extensions extensions). This method returns a CDK Exchange corresponding to the type of the specified pattern. |
- | Yes |
operation | Operation to call on a service. This parameter can be used in conjunction with the sending methods of the Listeners. If no operation is specified in the Message Exchange to send, this parameter will be used. | - | No |
timeout | Timeout in milliseconds of a synchronous send. This parameter can be used in conjunction with the sendSync(Exchange exchange) method of the Listeners. Set 0 for an infinite timeout. | 30000 | No |
Attribute | Description | Default value | Required |
---|---|---|---|
service-name | Web Service name to expose. | No
|
Service Unit descriptor
The service unit is configurable via its extensions in the jbi.xml file:
Service Unit content
The Service Unit has to contain the following elements, packaged in an archive:
- The META-INF/jbi.xml descriptor file as described above
Monitoring the component
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 |
MessageExchangeProcessorAbsoluteDurations | The aggregated durations of the working message exchange processor since the last startup of the component. | n-tuple value containing, in milliseconds:
|
no |
MessageExchangeProcessorRelativeDurations | The aggregated durations of the working message exchange processor on the last sample. | n-tuple value containing, in milliseconds:
|
no |
MessageExchangeProcessorThreadPoolActiveThreadsCurrent | The current number of active threads of the message exchange processor thread pool | instant integer value | no |
MessageExchangeProcessorThreadPoolActiveThreadsMax | The maximum number of threads of the message exchange processor thread pool that was active | 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 since the last startup of the component | instant integer value | no |
ServiceProviderInvocations | The number of service provider invocations grouped by:
|
integer counter value since the last startup of the component | no |
ServiceProviderInvocationsResponseTimeAbs | The aggregated response times of the service provider invocations since the last startup of the component grouped by:
|
n-tuple value containing, in millisecond:
|
no |
ServiceProviderInvocationsResponseTimeRel | The aggregated response times of the service provider invocations 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 thread is available to run a message exchange processor |
|
Dedicated alerts
No dedicated alert is available.