Hello,
I have the problem of memory leak, like Fabrice Landrodie, when a lot of
requests are sent to my
Service Unit.
Let me show you the code of the operation used:
@Operation(name = "test2")
public void test2(MessageExchange exchange) throws MessagingException {
String res = "<testResponse><NanoSec>10</NanoSec></testResponse>";
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
NormalizedMessage message = null;
if (exchange instanceof InOut == true) {
message = exchange.createMessage();
message.setContent(new StreamSource(new
StringReader(res)));
MessageUtil.transferToOut(message, exchange);
} else if (exchange instanceof InOnly == true) {
exchange.setStatus(ExchangeStatus.DONE);
}
}
channel.send(exchange);
}
I am using a client how send a lot of requests to this ServiceUnit and I can
see a lot of "org.apache.xerces.dom.DeferredDocumentImpl" objects created
but never free. I think the MessageExchange is still ACTIVE (so streams "in"
and "out" are never closed) but I don't know how and where I can modify the
MessageExchange's status to ExchangeStatus.DONE.
I tried your solution:
@Operation(name = "test2")
public void test2(MessageExchange exchange) throws MessagingException {
...
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
}
but this error occured:
ERROR - [servicemix-http] - Servlet.service() for servlet
servicemix-http threw exception
javax.jbi.messaging.MessagingException: illegal exchange status: done
at
org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExchangeImpl.java:626)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:385)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:431)
at
org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDeliveryChannel.java:79)
at
org.apache.servicemix.bean.BeanEndpoint$PojoChannel.send(BeanEndpoint.java:568)
at MyClass.test2(MySo1.java:299)
at ...
Do you have another idea?
Thanks
Regards,
Fabien BIDET
gnodet wrote:
>
> There's no real difference. Such thing is mandatory when using
> directly the DeliveryChannel too.
> If you don't, you may end up with threads locked forever or memory leaks.
> With the delivery channel, you'd do:
> exchange.setStatus(ExchangeStatus.DONE);
> channel.send(exchange);
> Btw, that's exactly what the client does.
>
>
--
View this message in context:
http://www.nabble.com/Servicemix-bean-MemoryLeak-tp15891209p17213172.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.