I am facing the issue where quartz doesn't start up. Is there anything wrong with my below config?
I have also requirement where i have to suspend the job at specific time and resume it again.
I have configured the policy using quartz as described in the link
https://camel.apache.org/manual/latest/cronscheduledroutepolicy.html
Any help or suggestions please?
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route routePolicyRef="testRoutePolicy">
<from uri="Reading from queue"/> // exact names are hidden due to security reasons
<transacted/>
<setHeader headerName="id">
<simple>${in.header.id}</simple>
</setHeader>
<to uri="bean:beanName1"/> // exact names are hidden due to security reasons
<log message="Got response: ${body}"/>
<to uri="Sending to another queue"/> // exact names are hidden due to security reasons
</route>
<route routePolicyRef="testRoutePolicy">
<from uri="Reading from queue"/>
<transacted/>
<setHeader headerName="id">
<simple>${in.header.id}</simple>
</setHeader>
<to uri="bean:beanName2"/>
<log message="Got response: ${body}"/>
<to uri="bean:beanName3"/>
</route>
<route routePolicyRef="testRoutePolicy">
<from uri="Reading from queue"/>
<transacted/>
<to uri="bean:beanName4"/>
<to uri="Sending to another queue"/>
</route>
</camelContext>
<bean id="testRoutePolicy" class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy">
<property name="routeStartTime" value="* * * * *"/>
<property name="routeSuspendTime" value="0 30 5 ? * SUN *"/>
<property name="routeResumeTime" value="0 0 8 ? * SUN *"/>
</bean>
Jboss Logs:
29/01/20 14:13:38,701 INFO [C3P0Registry] Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10] [main]
29/01/20 14:13:38,818 INFO [SpringCamelContext] Apache Camel 2.19.1 (CamelContext: camel) is starting [main]
29/01/20 14:13:38,820 INFO [ManagedManagementStrategy] JMX is enabled [main]
29/01/20 14:13:38,965 INFO [DefaultTypeConverter] Loaded 196 type converters [main]
29/01/20 14:13:39,018 INFO [DefaultRuntimeEndpointRegistry] Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000) [main]
29/01/20 14:13:39,147 INFO [QuartzComponent] Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX. [main]
29/01/20 14:13:39,177 INFO [StdSchedulerFactory] Using default implementation for ThreadExecutor [main]
29/01/20 14:13:39,180 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: main [main]
29/01/20 14:13:39,196 INFO [SchedulerSignalerImpl] Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl [main]
29/01/20 14:13:39,196 INFO [QuartzScheduler] Quartz Scheduler v.2.3.0 created. [main]
29/01/20 14:13:39,197 INFO [RAMJobStore] RAMJobStore initialized. [main]
29/01/20 14:13:39,202 INFO [QuartzScheduler] Scheduler meta-data: Quartz Scheduler (v2.3.0) 'DefaultQuartzScheduler-camel' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
[main]
29/01/20 14:13:39,203 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler-camel' initialized from an externally provided properties instance. [main]
29/01/20 14:13:39,203 INFO [StdSchedulerFactory] Quartz scheduler version: 2.3.0 [main]
Related
On 3 virtual machines running Zookeeper + ActiveMQ.
ActiveMQ Version 5.15.9 with Camel Version 2.19.5
Now, I'm using the embedded Camel EIP Framework in ActiveMQ.
I want to get a specific node from Zookeeper based on an event.
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- You can use Spring XML syntax to define the routes here using the <route> element -->
<route>
<description>Read zookeeper variant 1</description>
<from uri="activemq:example.zoo1"/>
<pollEnrich>
<constant>zookeeper://localhost:2182/some/node/99</constant>
</pollEnrich>
<to uri="activemq:example.zooRead1"/>
</route>
<route>
<description>Read zookeeper variant 2</description>
<from uri="activemq:example.zoo2"/>
<pollEnrich>
<constant>zookeeper:znode1:2182,znode2:2182,znode3:2182/some/node/99</constant>
</pollEnrich>
<to uri="activemq:example.zooRead2"/>
</route>
</camelContext>
In the Log File following exception occured with variant 1
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:729)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:92)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.PollEnricher.resolveEndpoint(PollEnricher.java:343)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.PollEnricher.process(PollEnricher.java:201)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)[camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[camel-jms-2.19.5.jar:2.19.5]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1168)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1160)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1057)[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_222]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_222]
2019-10-01 15:06:05,652 | DEBUG | Message exchange has failed: so breaking out of pipeline for exchange: Exchange[ID-Monkey-34387-1569942241018-0-1] Exception: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper | org.apache.camel.processor.Pipeline | Camel (camel) thread #1 - JmsConsumer[example.zoo1]
2019-10-01 15:06:05,690 | WARN | Execution of JMS message listener failed. Caused by: [org.apache.camel.ResolveEndpointFailedException - Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper] | org.apache.camel.component.jms.EndpointMessageListener | Camel (camel) thread #1 - JmsConsumer[example.zoo1]
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper
Camel Zookeeper Component
The solution works as #Bedla wrote.
Copy the Jar in the ACTIVEMQ_HOME/lib folder and it works as expceted.
I use servicemix. I'm trying to send messages from jetty to the queue, but I get the following error:
enter image description here
my blueprint:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="jetty:http://localhost:8180/test"/>
<to uri="activemq://events_test" />
</route>
</camelContext>
if i use route from jetty to file - everything works as it should
Exchange pattern of your route is InOut, so your jetty consumer waiting response from activemq producer. Response will appear if you have activemq consumer that will process your jetty request. If activemq producer shouldn't make response and you need just save request in queue use "inOnly" instead if "to", like this:
<inOnly uri="activemq://events_test" />
I have a mock endpoint at 8001 that will echo anything provided to it.
I have an http endpoint that will submit the end of the URL to the mock endpoint, and provide a response from the endpoint's response.
That works fine.
The challenge is, I want the http route to use only 1 tcp connection to the 8001 endpoint.
I created a worker group as explained elsewhere, and set the worker count to 1. Looking through the source code, I'm thinking this approach should work.
However, when I do this bash command:
for a in {1..5}; do curl "http://localhost:8080/upstream/REQUESTNUM$a" > $a.txt & done;
I see multiple connections to 8001. I would have expected the http endpoint requests would have to share a single pool worker, but that doesn't seem to be the case.
Perhaps I am missing something, or perhaps there is another way to accomplish my goal of using only 1 back-end tcp connection for all the http requests.
How do I accomplish it?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext
xmlns="http://camel.apache.org/schema/spring">
<route id="mockUpstream">
<from
uri="netty4:tcp://localhost:8001?sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true" />
<log message="Incoming to upstream: ${body}" />
<transform>
<simple>${body}</simple>
</transform>
</route>
<route id="httpServer">
<from
uri="netty4-http:http://0.0.0.0:8080/upstream?matchOnUriPrefix=true" />
<!-- optional just use CamelHttpQuery from header, for full query -->
<log
message="Incoming http command: ${in.headers[CamelHttpPath]}" />
<transform>
<simple>${in.headers[CamelHttpPath]}</simple>
</transform>
<to
uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true" />
<transform>
<simple>${body}</simple>
</transform>
</route>
</camelContext>
<bean id="poolBuilder"
class="org.apache.camel.component.netty4.NettyWorkerPoolBuilder">
<property name="workerCount" value="1" />
</bean>
<bean id="sharedPool" class="io.netty.channel.EventLoopGroup"
factory-bean="poolBuilder" factory-method="build"
destroy-method="shutdown">
</bean>
</beans>
Looking at the logs, with TRACE level logging, I saw the NettyProducer's pool was indeed set to use 1 max active connection, but the NettyProducer was allowed 100 idle connections. I changed the following line and it is now behaving as expected:
<to
uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true&producerPoolMaxActive=1&producerPoolMaxIdle=1" />
I assumed the "producer" settings were only good for the producer side (netty in mock host route) of the connection, but it looks like they can be used by the consumer end (netty in http route), too.
edit: I confused the terms producer and consumer and got that backwards above. Seeing that the "to" element is producing a request for something to consume, the producer* parameters make sense for (netty in http route). The (netty in mock host route) is the consumer of requests.
I currently am using ServiceMix to route messages using QPID libraries.
My working config is below :
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="amqp" class="org.apache.camel.component.amqp.AMQPComponent">
<property name="connectionFactory">
<bean class="org.apache.qpid.jms.JmsConnectionFactory">
<property name="remoteURI" value="failover:amqps://remote-broker:9551?transport.trustStoreLocation=/vault/QA_UM_A.jks />
</bean>
</property>
</bean>
<bean id="kubeActivemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://10.100.10.13:61616" />
</bean>
<route>
<from uri="amqp:queue:///queue-1" />
<to uri="kubeActivemq:local-queue?jmsMessageType=Text" />
</route>
</camelContext>
</blueprint>
The above config works.
Now I need to implement durable subscription so that if servicemix goes down, it is able to recover all messages when it comes back up (the ones sent when servicemix is down.)
Based on the documentation , I have implemented a route :
<route>
<from uri="amqp:queue:///queue-1?clientId=1&durableSubscriptionName=bar1" />
<to uri="kubeActivemq:queue:///local-queue" />
</route>
But this implementation gives the ERROR :
2018-05-28 13:28:58,421 | ERROR | mix-7.0.0/deploy | BlueprintCamelContext | 40 - org.apache.camel.camel-blueprint - 2.16.4 | Error occurred during starting Camel: CamelContext(camel-1) due A durable subscription requires a topic (pub-sub domain)
java.lang.IllegalArgumentException: A durable subscription requires a topic (pub-sub domain)
at org.springframework.jms.listener.AbstractMessageListenerContainer.validateConfiguration(AbstractMessageListenerContainer.java:435)
at org.springframework.jms.listener.AbstractJmsListeningContainer.afterPropertiesSet(AbstractJmsListeningContainer.java:157)
at org.apache.camel.component.jms.JmsConsumer.prepareAndStartListenerContainer(JmsConsumer.java:163)
at org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:155)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3234)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3528)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3464)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3394)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3162)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3018)
.
.
.
Is there something Ive missed here ? Arent the topic names supposed to be same as queue names ?
Your route is instructing Camel to connect to a queue, and you need to change it to use a 'topic' for Durable Subscriptions. (Queue subscriptions are durable by default)
amqp:queue:///queue-1...
And Durable Subscriptions require a topic
amqp:topic:///topic-1...
I want to test camel spring integration example from the apache camel site
http://camel.apache.org/springintegration.html but I am getting the exception
org.apache.camel.RuntimeCamelException: org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel outputchannel.
my short code is given below:
<channel id="inChannel"/>
<channel id="outputChannel"/>
<beans:bean id="greeting" class="com.javarticles.spring.integration.Greeting"/>
<service-activator input-channel="inChannel" ref="greeting" method="sayHello" output-channel="outputChannel"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:activemqsource"/>
<to uri="log:input"/>
<to uri="spring-integration:inChannel? inputChannel=outputChannel"/>
<to uri="log:output"/>
</route>
I tried to search related problems but I did not get with camel could any one tell me how to subscribe the outputchannel
According to the Camel documentation mentioned by you, the config should be like this:
<to uri="spring-integration:inputChannel?inOut=true&inputChannel=outputChannel"/>
Your issue is inOut=true:
The exchange pattern that the Spring integration endpoint should use. If inOut=true then a reply channel is expected, either from the Spring Integration Message header or configured on the endpoint.