Petals-SE-POJO 2.0.x

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (16)

View Page History
* all methods can throws Exceptions.

A sample class following those rules:

h3. Process a service in the synchronous way

A sample class following the above rules for processing service in the synchronous way:
{code:java}
package test;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.component.ComponentContext;
import org.ow2.petals.component.framework.api.message.Exchange;
[...]
import org.ow2.petals.component.framework.listener.AbstractJBIListener;

public class SamplePojoService {
AbstractJBIListener jbiListener;
Logger logger;
ComponentContext ctx;

public void setJBIListener(AbstractJBIListener jbiListener) {
this.jbiListener = jbiListener;
this.logger = logger;
}

public boolean onExchange(Exchange exchange)
throws MessagingException {
return true;
}

public void init() {
logger.log(Level.INFO, "SamplePojo inits.");
}
{code}
The method {{onExchange(Exchange exchange)}} is invoked when a MessageExchange targeting the POJO service is
received on the component. The POJO service must process the service here.
If the POJO service sets a response on the exchange to support patterns {{InOut}} or {{InOptionalOut}}, the method has to return {{true}}. The component will send the response back.
Otherwise, the method return {{false}} and the component responds with a DONE acknowledgement.
If an exception is raised, depending of the nature of the exception ({{RuntimeException , FaultException}}...) and the pattern, a Fault or an ERROR acknowledgement will be sent.

The method {{onExchange(Exchange exchange)}} is invoked when an exchange is received from the component that is addressed to the current POJO endpoint.
The POJO must process the service in that method.
The POJO can invoke any 'sub-service' during its processing by synchronous invocations using the {{jbiListener}} instance.
If the POJO service must reply with a message {{OUT}} or {{FAULT}}, according to the MEP, the method must build and set the message to the current exchange.
Then, the method musts return {{true}} to delegate the effective send back of the response or acknowledgment (according to the MEP) to the CDK.
The exceptions should be handled properly during the processing of the method, and set accordingly as error or fault to the exchange.
However, mishandled exceptions will be handled by the CDK as generic exceptions.

h3. Process a service in the asynchronous way

h2. Service Configuration




|| {color:#333333}Parameter{color} || {color:#333333}Description{color}\\ || {color:#333333}Default{color}\\ || {color:#333333}Required{color}\\ ||
| provides | Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. | \- | Yes |
{table-plus}

{table-plus}






|| {color:#333333}Parameter{color} || {color:#333333}Description{color}\\ || {color:#333333}Default{color}\\ || {color:#333333}Required{color}\\ ||
| timeout | Timeout in milliseconds of a synchronous send. This parameter is used by the method {{sendSync}} (Exchange exchange) proposes by the CDK {{Listeners}} classes. \\



|| Parameter \\ || Description || Default value || Required ||
| class-name \\ | The name of the Java class to expose as a service. \\ | \- \\ | Yes \\ |



|| {color:#333333}Parameter{color} || {color:#333333}Description{color} || {color:#333333}Default{color} || {color:#333333}Required{color} || {color:#333333}Required{color} ||
| 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 |

{table-plus}

{table-plus}
{petalslink}{include:0 CDK Component Configuration Table}{petalslink}