How and where to check certain Apache Camel settings - java

I have a Camel-based app that publishes/subscribes messages to/from an ActiveMQ instance with routes like:
<from uri="activemq:myQueue" />
or:
<to uri="activemq:someOtherQueue" />
I'm trying to determine if I've inadvertently set my app up in "synchronous mode", which happens when either:
ActiveMQConnectionFactory#setAlwaysSyncSend is true; or
The "MessageProducer" is set to "Persistent"
I believe that, sans Camel, I would ordinarily be setting these properties manually. Introducing Camel as the ActiveMQ client here, not sure how/where to go to find what the value of these properties are. Any ideas? Thanks in advance.

You configure these values when you add the component by setting them on the connection URI that is passed to the ActiveMQ component. This documentation on the Camel website shows you how its done.
The ActiveMQ client does some of its own optimizations to improve performance on sends by choosing to use async over sync in some cases. This is documented here and is worth a read.
So you would configure the component when you add it via code like this:
camelContext.addComponent("activemq", activeMQComponent("tcp://localhost:61616?jms.alwaysSyncSend=true"));
The ActiveMQConnectionFactory configuration options are documented in detail here and the options applicable to Transports are here

Related

Apache camel don´t use all the dynamic queues created

I'm using apache camel for consuming an IBM Mq, I use jms for that, everything is ok that works fine, but in the performance testing the api create a lot of dynamic queues but just use once, I've used a lot of properties for solve this problem but I didn't get it yet. my api use a pattern InOut so the responses are in queue in a dynamic queue, when exist a lot of them, for example my api create 50 dynamic queues, but just use 3 of them.
Here are the properties I used to solve it, but didn´t work for me:
-maxConcurrentConsumers
-conccurrentConsumers
-threads
I found a solution for this and is this.
this is my consume to mq
.setHeader("CamelJmsDestinationName",
constant("queue:///"+queue+"?targetClient=1"))
.to("jms://queue:" + queue
+"?exchangePattern=InOut"
+"&replyToType=Temporary"
+"&requestTimeout=10s"
+"&useMessageIDAsCorrelationID=true"
+"&replyToConcurrentConsumers=40"
+"&replyToMaxConcurrentConsumers=90"
+"&cacheLevelName=CACHE_CONSUMER")
.id("idJms")
and this is the properties to connect the mq
ibm.mq.queueManager=${MQ_QUEUE_MANAGER}
ibm.mq.channel=${MQ_CHANNEL}
ibm.mq.connName=${MQ_HOST_NAME}
ibm.mq.user=${MQ_USER_NAME}
ibm.mq.additionalProperties.WMQ_SHARE_CONV_ALLOWED_YES=${MQ_SHARECNV}
ibm.mq.defaultReconnect=${MQ_RECONNECT}
# Config SSL
ibm.mq.ssl-f-i-p-s-required=false
ibm.mq.user-authentication-m-q-c-s-p=${MQ_AUTHENTICATION_MQCSP:false}
ibm.mq.tempModel=MQMODEL
the issue was in the MQ Model, the MQModel has to be shared if you are using the pattern inOut, this is because the concurrent create dynamic queues using the mqModel

How to specify which topic to listen to in kafka confluent connector?

I have been working on a kafka connector lately & i wanted to know where to configure the topics my sink connector's worker task should listen at.
Typically a SinkConnectorConfig looks like this
name=MySinkConnector
tasks.max=1
connector.class=com.operative.creative.bi.sink.MySinkConnector
topics=demo
filePath=/tmp/output.txt
and these settings can be overridden when using the rest-proxy to control the worker configs. I want to know where do we specify the topic.
I know the property file defines a property called "topics" but i didn't see anything reading it in the boiler plate code.
Any help will be appreciated.
topic = props.get(TOPIC_CONFIG);
Have a look at https://docs.confluent.io/current/connect/devguide.html#connector-example, and also https://gist.github.com/jcustenborder/b9b1518cc794e1c1895c3da7abbe9c08

Trying to capture response from ActiveMQ in my camel route

I am attempting to create a camel route using blueprint that sends a message on an activeMQ queue then listens to the response on the temporary queue created in the request. This seems pretty basic, but I can't find an example that utilizes it.
I have tried searching and reading the docs and here's what I've found:
http://camel.apache.org/jms.html
http://camel.apache.org/exchange-pattern.html
http://camel.apache.org/request-reply.html
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/EIP_Transaction_Guide/files/FMRTxnJMSSynchronous.html
http://kosalads.blogspot.com/2014/04/ApacheCamelRequestReplyPatternWithJavaDS.html
http://grokbase.com/t/camel/users/128n88xeva/how-to-use-request-reply-in-jms
http://camel.465427.n5.nabble.com/ExchangePattern-InOut-I-Can-t-get-any-response-td5056301.html
https://examples.javacodegeeks.com/enterprise-java/apache-camel/apache-camel-exchange-example/
Which is frustrating.
I have my activeMQ component set up such:
<to pattern="InOut" uri="activemq:queue:tripRequest.updateStatus.v1.0?useMessageIDAsCorrelationID=true"/>
<log message="Update Status responded ${out.body}"/>
The log shows the input XML, which surprised me. After checking the docs, I created a new activeMQ instance that listens to the same queue and dumps to a log, but this threw errors and it keeps mixing up my log and unmarshal objects on my other route.
How can I accomplish this?
Check the answer in the link below. It should give you hints on how to build your active-mq uri for a request/reply scenario.
Implement Request-Reply pattern using ActiveMQ, Camel and Spring

how to make persistent JMS messages with java spring boot application?

I am trying to make a queue with activemq and spring boot using this link and it looks fine. What I am unable to do is to make this queue persistent after application goes down. I think that SimpleJmsListenerContainerFactory should be durable to achieve that but when I set factory.setSubscriptionDurable(true) and factory.setClientId("someid") I am unable to receive messages any more. I would be greatfull for any suggestions.
I guess you are embedding the broker in your application. While this is ok for integration tests and proof of concepts, you should consider having a broker somewhere in your infrastructure and connect to it. If you choose that, refer to the ActiveMQ documentation and you should be fine.
If you insist on embedding it, you need to provide a brokerUrl that enables message persistence.
Having said that, it looks like you misunderstand durable subscriber and message persistence. The latter can be achieved by having a broker that actually stores the content of the queue somewhere so that if the broker is stopped and restarted, it can restore the content of its queue. The former is to be able to receive a message even if the listener is not active at a period of time.
you can enable persistence of messages using ActiveMQConnectionFactory.
as mentioned in the spring boot link you provided, this ActiveMQConnectionFactory gets created automatically by spring boot.so you can have this bean in your application configuration created manually and you can set various property as well.
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");
Here is the link http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

CamelContext doesn't startup if one route is misconfigured

We use Java DSL to configure our routes. All configurations for routes are in a db table and can be configured via a GUI.
How is it possible to ensure that the camelContext starts up even if a route is misconfigured (e.g. .to(invalidurl or typo) in a route or simply a bug in a route)?
Is there a possibilty to validate the routes before starting or maybe better some parameters/options which can be set on the context itself?
You can configure the routes with .autoStartup(false), and then start the routes manually when CamelContext has been started up.
To validate its really depending on what kind of component it is. If its some database component you can write some code that does a SQL query to see if the is valid user login or something.
To validate that an endpoint uri is misconfigured, then that is harder as they have a ton of options. But this is getting improved from Camel 2.16 onwards where we have during build time some tooling that generates a json schema file with the options, then we could potentially leverage that during parsing the routes to check for invalid configuration before attempting to create the endpoints which could detect errors sooner, and even also with IDE plugins or other 3rd party tooling.
Can you just before adding every route to the context, add it to a separate "test" context individually, and see if it spins up or fails; then based on that add it to your real context?

Categories

Resources