|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (11)
View Page History* a {{public boolean onExchange(Exchange exchange)}} MUST be provided.
* an {{public boolean onAsyncExchange(Exchange exchange, AsyncContext asyncContext)}} CAN be provided, optionally.
* an {{public boolean onAsyncExchange(Exchange exchange, AsyncContext asyncContext)}} CAN be provided, optionally.
* all methods can throw Eexceptions.
public void init() {
logger.log(Level.INFO, "Sample Pojo inits.");
}
}
}
h3. Process a service in the asynchronous way
A sample class following the above rules for processing service in the asynchronous way:
{code:java}
package test;
import java.util.logging.Level;
[...]
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;
}
public void setComponentContext(ComponentContext ctx) {
this.ctx = ctx;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
public boolean onExchange(Exchange exchange)
throws MessagingException {
[...]
jbiListener.sendASync(anotherExchange);
[...]
return true;
}
public boolean onAsyncExchange(Exchange exchange, AsyncContext asyncContext)
throws MessagingException {
[...]
jbiListener.sendASync(anotherExchange);
[...]
return true;
}
public void init() {
logger.log(Level.INFO, "Sample Pojo Async inits.");
}
}
{code}
Processing a service in asynchronous way is the best approach when targeting performance, but it's more tedious to develop, and demands an average level in Petals development.
Basically, all is in the data that permit to correlate asynchronous sent exchange and their asynchronous response.
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 |
| 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. \\
| timeout | Timeout in milliseconds of a synchronous send. This parameter is used by the method {{sendSync}} (Exchange exchange) proposes by the CDK {{Listeners}} classes. \\
h3. Service Unit descriptor
h3. Service Unit content
h1. Component Configuration
{table-plus}
{table-plus}
|| {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 |
| 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 |