You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "eubinas (JIRA)" <ji...@apache.org> on 2009/12/21 15:21:52 UTC
[jira] Reopened: (CAMEL-2292) RejectedExecutionException after
restarting camel context
[ https://issues.apache.org/activemq/browse/CAMEL-2292?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
eubinas reopened CAMEL-2292:
----------------------------
So I changed the startSendStop function to the following and I still get the same exception. Is the producerTemplate stopping correctly?
private void startSendStop() throws Exception
{
final SpringCamelContext springCamelContext = (SpringCamelContext)this.applicationContext.getBean(Constants.CAMEL_CONTEXT_NAME);
final ProducerTemplate producerTemplate;
final Endpoint serverRequestQueue;
springCamelContext.start();
producerTemplate = springCamelContext.createProducerTemplate();
serverRequestQueue = springCamelContext.getEndpoint("serverRequestQueue");
final Exchange exchange = producerTemplate.send(serverRequestQueue, new Processor()
{
public void process(final Exchange exchange) throws Exception
{
exchange.setPattern(ExchangePattern.InOut);
exchange.getIn().setHeader(ServerJmsServices.REQUEST, ServerJmsServices.GET_SYMBOL_INFO);
exchange.getIn().setBody("");
}
});
final String responseString = (String)exchange.getOut().getBody();
Assert.assertTrue(responseString.length() > 0);
producerTemplate.stop();
springCamelContext.stop();
}
> RejectedExecutionException after restarting camel context
> ---------------------------------------------------------
>
> Key: CAMEL-2292
> URL: https://issues.apache.org/activemq/browse/CAMEL-2292
> Project: Apache Camel
> Issue Type: Bug
> Affects Versions: 2.1.0
> Reporter: Hadrian Zbarcea
> Assignee: Claus Ibsen
> Fix For: 2.2.0
>
>
> User reported over the #camel channel the following exception trying to send a message after the context was stopped and restarted
> "Failed to create Producer for endpoint:". Thats the exception I'm getting
> Reason: java.util.concurrent.RejectedExecutionException
> {code}
> Exception in thread "core" org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[activemq://queue:request.lavaOrderProducer.powerTraderServer]. Reason: java.util.concurrent.RejectedExecutionException
> at org.apache.camel.component.jms.JmsProducer.testAndSetRequestor(JmsProducer.java:116)
> at org.apache.camel.component.jms.JmsProducer.processInOut(JmsProducer.java:175)
> at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:147)
> at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:179)
> at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:161)
> at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
> at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:160)
> at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:98)
> at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
> at com.wjb.producer.lavaData.dispatcher.ServerRequestDispatcher.requestSymbolSectorArray(ServerRequestDispatcher.java:122)
> at com.wjb.producer.core.LavaDataManager.initialize(LavaDataManager.java:64)
> at com.wjb.producer.core.ProducerCore.run(ProducerCore.java:98)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.util.concurrent.RejectedExecutionException
> at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760)
> at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
> at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:216)
> at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:366)
> at org.apache.camel.util.DefaultTimeoutMap.schedulePoll(DefaultTimeoutMap.java:156)
> at org.apache.camel.util.DefaultTimeoutMap.<init>(DefaultTimeoutMap.java:52)
> at org.apache.camel.component.jms.requestor.Requestor.<init>(Requestor.java:68)
> at org.apache.camel.component.jms.JmsProducer.testAndSetRequestor(JmsProducer.java:107)
> {code}
> The following unit tests seems to reproduce the problem:
> {code}
> ublic final class StartStopTest
> {
> private final GenericApplicationContext applicationContext = new GenericApplicationContext();
> private final int testCount = 3;
>
> @Test
> public void test() throws Exception
> {
> //Initialize
> final File propertiesFile = new File(Constants.RESOURCE_DIRECTORY_NAME, Constants.PROPERTIES_FILE_NAME);
> PropertyConfigurator.configure(propertiesFile.getPath());
>
> final File applicationContextFile = new File(Constants.RESOURCE_DIRECTORY_NAME, Constants.CONTEXT_FILE_NAME);
> final Resource applicationContextResource = new FileSystemResource(applicationContextFile);
>
> final AbstractBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(this.applicationContext);
>
> beanDefinitionReader.loadBeanDefinitions(applicationContextResource);
> this.applicationContext.refresh();
>
> //Begin Testing
> for (int i = 0; i < this.testCount; i++)
> {
> this.startSendStop();
> Thread.sleep(3000);
> }
> }
>
> private void startSendStop() throws Exception
> {
> final SpringCamelContext springCamelContext = (SpringCamelContext)this.applicationContext.getBean(Constants.CAMEL_CONTEXT_NAME);
> final ProducerTemplate producerTemplate;
> final Endpoint serverRequestQueue;
>
> springCamelContext.start();
>
> producerTemplate = springCamelContext.createProducerTemplate();
> serverRequestQueue = springCamelContext.getEndpoint("serverRequestQueue");
>
> final Exchange exchange = producerTemplate.send(serverRequestQueue, new Processor()
> {
> public void process(final Exchange exchange) throws Exception
> {
> exchange.setPattern(ExchangePattern.InOut);
> exchange.getIn().setHeader(ServerJmsServices.REQUEST, ServerJmsServices.GET_SYMBOL_INFO);
> exchange.getIn().setBody("");
> }
> });
> final String responseString = (String)exchange.getOut().getBody();
>
> Assert.assertTrue(responseString.length() > 0);
>
> springCamelContext.stop();
> }
> }
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:camel="http://camel.apache.org/schema/spring"
> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
>
> <!-- ActiveMQ component for Camel to use -->
> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
> <property name="connectionFactory">
> <bean class="org.apache.activemq.ActiveMQConnectionFactory">
> <property name="brokerURL" value="tcp://192.168.5.10:61616?daemon=true" />
> </bean>
> </property>
> </bean>
>
> <!-- Camel Context -->
> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
> <camel:endpoint id="serverRequestQueue" uri="activemq:queue:request.lavaOrderProducer.powerTraderServer" />
> </camelContext>
> </beans>
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.