I have the route and processor below reading a JMS message and writing the
contents to a file via SFTP. When the SFTP component cannot connect (in my
test, wrong user) after 6 attempts, I have what seems to be a deadlock on
the writer close. Am I doing something wrong? Also, with or without the
connection issue, over time 10 producer template threads are created. Don't
know why this happens as I thought that there would only be 2 that would
support the 2 JMS consumers.
Camel version 2.12.1
Spring snippet:
<bean id="myProcessor" class="MyProcessor">
<property name="producerTemplate" ref="myProducer"></property>
</bean>
<camel:template id="myProducer" camelContextId="test"/>
<camel:camelContext id="test">
<camel:route>
<camel:from
uri="jms:queue:from?concurrentConsumers=2"></camel:from>
<camel:process ref="myProcessor"></camel:process>
</camel:route>
</camel:camelContext>
MyProcessor class:
public class MyProcessor implements Processor {
private ProducerTemplate producerTemplate;
@Override
public void process(Exchange exchange) throws Exception {
String uri = "sftp://host:81/To?username=user&password=mypass";
PipedOutputStream pipedOutputStream = new PipedOutputStream();
PipedInputStream pipedInputStream = new
PipedInputStream(pipedOutputStream);
Endpoint endpoint = exchange.getContext().getEndpoint(uri);
Exchange newExchange = endpoint.createExchange();
newExchange.getIn().setBody(pipedInputStream,
InputStream.class);
Future<Exchange> future =
this.getProducerTemplate().asyncSend(endpoint,
newExchange);
Writer writer = new OutputStreamWriter(pipedOutputStream);
writer.write(exchange.getIn().getBody(String.class));
writer.close();
future.get();
}
public ProducerTemplate getProducerTemplate() {
return producerTemplate;
}
public void setProducerTemplate(ProducerTemplate producerTemplate) {
this.producerTemplate = producerTemplate;
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/ProducerTempate-asyncSend-using-PipedInputStream-tp5748300.html
Sent from the Camel - Users mailing list archive at Nabble.com.