Следуя предложению, приведенному в комментариях, я получил его с помощью ProducerTemplate :
package com.mypackage;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.impl.DefaultShutdownStrategy;
import org.apache.camel.spi.RouteStartupOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Custom implementation for gracious shutdown.
*/
@Component
public class MyCustomShutdownStrategy extends DefaultShutdownStrategy {
private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomShutdownStrategy.class);
@Autowired
public MyCustomShutdownStrategy() {}
@Override
protected boolean doShutdown(
CamelContext context,
List<RouteStartupOrder> routes,
long timeout,
TimeUnit timeUnit,
boolean suspendOnly,
boolean abortAfterTimeout,
boolean forceShutdown)
throws Exception {
boolean shutdownComplete =
super.doShutdown(
context, routes, timeout, timeUnit, suspendOnly, abortAfterTimeout, forceShutdown);
if (shutdownComplete) {
clearSomeEntries(context);
}
return shutdownComplete;
}
private void clearSomeEntries(CamelContext context) {
LOGGER.info("Do some clean-up...");
ProducerTemplate template = context.createProducerTemplate();
template.setDefaultEndpointUri("mybatis:removeDataFromDatabase?statementType=Update");
template.sendBody("hi");
}
}