Hi,
I need some help for configuring thread-pools for a component. Can
any one send me a sample servicemix.xml file where the executor factory is
configured.
In my servicemix.xml a component called FileWrite is configured. the
configuration is as below.
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:nms="http://util.file.com/getFile">
<sm:serviceunit id="jbi">
<sm:activationSpecs>
<sm:activationSpec component="FileWrite" service="nms:FileWrite"
endpoint="endpoint">
<sm:component>
<bean class="com.file.util.FileWriteComponent">
<property name="filename" value="C:/duns/LinkageDuns.txt"/>
</bean>
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:serviceunit>
</beans>
The File write component is as below which writes an incoming message into
an output file.
public class FileWriteComponent extends ComponentSupport implements
MessageExchangeListener {
private Log log = LogFactory.getLog(FileWriteComponent.class);
private String filename;
private SourceTransformer sourceTransformer = new SourceTransformer();
private OutputStreamWriter osw;
private BufferedWriter bw;
@Override
public void start() throws JBIException {
super.start();
try {
osw = new OutputStreamWriter(new
FileOutputStream(filename, true));
bw = new BufferedWriter(osw);
} catch (Exception e) {
throw new JBIException(e);
}
}
@Override
public void stop() throws JBIException {
super.stop();
try {
osw.flush();
osw.close();
} catch (IOException e) {
throw new JBIException(e);
}
}
public void onMessageExchange(MessageExchange exchange)
throws MessagingException {
NormalizedMessage message = exchange.getMessage("in");
Document doc = null;
try {
String mess =
sourceTransformer.contentToString(message);
System.out.println("File Write Component : " + mess );
//doc = sourceTransformer.toDOMDocument(message);
log.debug("Incoming message : " +
sourceTransformer.toString(doc));
bw.write(mess + "\n");
bw.flush();
} catch (Exception e) {
throw new MessagingException(e);
}
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
}
Please help me in making the above component multi threaded using thread
pools.
Let me know what needs to added in the servicemix.xml and to the
FileWriteComponent.
--
View this message in context:
http://www.nabble.com/Service-mix-thread-pools-tf4028734s12049.html#a11443657
Sent from the ServiceMix - User mailing list archive at Nabble.com.