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
Related
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
I have tried to implement a simple application with Apache Camel and RabbitMQ. Below is the route that I have:
from("direct:startQueuePoint")
.id("idOfQueueHere")
.marshal(jsonDataFormat)
.to("rabbitmq:tasks?hostname=localhost&port=5672&autoDelete=false&routingKey=camel")
.end();
When I run the spring boot application which runs this route, it throws an error:
because of No endpoint could be found for: rabbitmq://tasks?autoDelete=false&hostname=localhost&port=5672&routingKey=camel, please check your classpath contains the needed Camel component jar
I created an exchange by name 'tasks' in RabbitMQ management console and binded it to the queue 'task_queue' with the routing key 'camel'. I could see in the netstat that the port 5672 is running the erlang exe.
I am not sure what mistake I am making here. Could someone please help me out here?
I am using camel kafka component 2.19 (Latest). I am initializing kafka producer endpoint with "my-topic". but topic is calculated at the runtime say "my-error-topic" and I set it in the header so the message is produced to "my-error-topic". Everything works fine.
The problem is when messageHistory is logged, it logs initial route with the topic which I used for initialization which makes it misleading information for support guys because it gives them an idea that message is produced to "my-topic." As a workaround, I have stopped logging message history. But still I got it in logs from defaultErrorHandler.log(). Hence it is still misleading.
Please tell me the solution.
No this is correct as it does it, as it logs the endpoint url from the route (eg you can find exactly where in the route it was). Any kind of header override is a special use-case here, you can log the headers if you use error handling in Camel where you can log anything you want, such as the exception message, stacktrace, message body, headers etc.
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
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