ActiveMQ Request-Reply timeout - activemq

I have this activeMQ issue where I send a request to a remote broker (from a Camel Application). See config below:
<bean id="providerJMSConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="alwaysSessionAsync" value="false"/>
<property name="alwaysSyncSend" value="true"/>
<property name="brokerURL"><value>${remote-broker-url}</value></property>
<property name="clientID" value=""/>
<property name="closeTimeout" value="150000"/>
<property name="copyMessageOnSend" value="true"/>
<property name="disableTimeStampsByDefault" value="false"/>
<property name="dispatchAsync" value="false"/>
<property name="objectMessageSerializationDefered" value="false"/>
<property name="optimizeAcknowledge" value="true"/>
<property name="optimizedMessageDispatch" value="true"/>
<property name="password" value=""/>
<property name="producerWindowSize" value="0"/>
<property name="statsEnabled" value="false"/>
<property name="useAsyncSend" value="false"/>
<property name="useCompression" value="false"/>
<property name="useRetroactiveConsumer" value="false"/>
<property name="userName" value=""/>
<property name="watchTopicAdvisories" value="true"/>
<property name="sendTimeout" value="0"/>
</bean>
<bean id="aeroProviderJMSConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="providerJMSConnectionFactory"/>
<property name="deliveryPersistent" value="true"/>
<property name="explicitQosEnabled" value="true"/>
<property name="priority" value="${jms-message-priority}"/>
<property name="acceptMessagesWhileStopping" value="false"/>
</bean>
<bean id="providerJMS" class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="providerJMSConfig"/>
</bean>
<osgi:camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
<endpoint id="providerEndpoint" uri="providerJMS:queue:provider?replyTo=providerResponse&requestTimeout=120000"/>
<route>
<from .....>
<to ref="providerEndpoint"/>
....
</route>
Whenever I check the "providerResponse" queue on the remote broker, I realise the resposne message is never picked up. it remains in the message even I had asked response messages be queued in there (which was actually done).
My question is, why will the Camel refuse to get this message from this queue?
Note that Exchange pattern was explicitly set to InOut.
I noticed it said the CorrelationID were not the same even though I check the JMSCorrelationID for the request and the response which look the same to me.
Is there an alternate Selector I can use for matching JMS Request/Reply response?

Rather than using <to ref="providerEndpoint"/> try <inOut ref="providerEndpoint"/>. If you omit the replyTo parameter on the URI, Camel wil create a temporary queue to be used for that response only.

Related

How to configuration Oracle connection pool in ActiveMQ

I want to configure the number of connection pools in ActiveMQ for the Oracle database. What should I do for this purpose? My current configuration is as follows:
<bean id="oracle-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:#10.10.10.10:1521:hmdservicename"/>
<property name="username" value="hmd"/>
<property name="password" value="hmd"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
My ActiveMQ version is 5.16.3.
You can find all the details for configuring BasicDataSource in the DBCP documentation. You can configure the maximum number of connections in the pool using the maxTotal property, e.g.:
<bean id="oracle-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:#10.10.10.10:1521:hmdservicename"/>
<property name="username" value="hmd"/>
<property name="password" value="hmd"/>
<property name="poolPreparedStatements" value="true"/>
<property name="maxTotal" value="25"/>
</bean>

Disable RFH2 headers while posting message to IBM MQ via JMS bridge

I am publishing message to ActiveMQ queue (TEST.AMQ.QUEUE), which is Bridged to IBM MQ queue (TEST.IBM-MQ.QUEUE) by the following configuration in activmq.xml:
<bean id="remoteFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="username" value="***"></property>
<property name="password" value="***"></property>
<property name="targetConnectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="1*.2*6.**.***" />
<property name="port" value="1*1*" />
<property name="queueManager" value="Q****HUB" />
<property name="channel" value="Q*****D" />
<property name="transportType" value="1" />
</bean>
</property>
</bean>
<!-- Configure JMS bridge -->
<jmsBridgeConnectors>
<jmsQueueConnector outboundQueueConnectionFactory="#remoteFactory">
<outboundQueueBridges>
<outboundQueueBridge outboundQueueName="TEST.IBM-MQ.QUEUE" />
</outboundQueueBridges>
</jmsQueueConnector>
</jmsBridgeConnectors>
I need to set the property TARGCLIENT as MQ, to disable RFH2 headers, how can i provide this property in activemq.xml file, in which my bridge configurations are defined.
The targetClient property can be set on queues, but I'm not sure where it will fit with the bridge.
Could try this name:
queue:///TEST.IBM-MQ.QUEUE?targetClient=1
Or maybe define a bean, and reference that:
<bean id="queue" class="com.ibm.mq.jms.MQQueue"
depends-on="remoteFactory">
<property name="baseQueueManagerName" value="*queue manager*" />
<property name="baseQueueName" value="TEST.IBM-MQ.QUEUE" />
<property name="targetClient" value="1" />
</bean>

Excess of Redis connections created and idle connections not used

Following is my jedis pool configuration:
Excess of connections are created as the existing ones are not used. What is the purpose of pool if every function creates new connection.
Please let me know if anybody can provide solution to this.
`<bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="true" />
<property name="whenExhaustedAction" value="2" />
<property name="maxIdle" value="40" />
<property name="minIdle" value="30" />
<property name="softMinEvictableIdleTimeMillis" value="60000" />
<property name="timeBetweenEvictionRunsMillis" value="600000" />
</bean>
<bean id="jedisFactoryPrimary"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="poolConfig"><ref bean="jedisConfig"/></property>
<property name="hostName" value="${redis-db.hostname}"></property>
<property name="password" value="${redis-db.password}"></property>
<property name="port" value="${redis-db.port}"></property>
</bean>`

How to Setup SSL for Camel Route using the embedded Active MQ Broker in a service mix?

I am trying to use blueprint XML for the setup
My Blueprint XML looks like this
<?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">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="file:activemq/input"/>
<to uri="file:activemq/output"/>
<setBody>
<simple>
FileMovedEvent(file: ${file:name}, timestamp: ${date:now:hh:MM:ss.SSS})
</simple>
</setBody>
<to uri="activemqs:queue:Main.Queue.Vibhav"/>
</route>
</camelContext>
<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQSslConnectionFactory">
<property name="brokerURL" value="ssl://localhost:61616" />
<property name="keyStore" value="file:C:/Users/xxx/Desktop/apache-servicemix-4.5.3/etc/myclient.ks"/>
<property name="keyStorePassword" value="test123"/>
<property name="trustStore" value = "file:C:/Users/xxx/Desktop/apache-servicemix-4.5.3/etc/myclient.ts"/>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="8" />
<property name="connectionFactory" ref="activemqConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<bean id="activemqs" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
</blueprint>
Note: In the broker I have already added the ssl context and the ssl connectors, also the plugin which has ssl certificate with the jaas realm.
I fixed this issue by setting the trust store password in the connection factory properties.

How to configure heartbeat for spring-rabbitmq

How can I configure spring-rabbitmq connection-factory
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
username="guest" password="guest"/>
With a requested heartbeat ?
You can provide the underlying connection factory as a bean, properties set on the rabbit:connection-factory will be overridden.
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
username="guest" password="guest" connection-factory="rcf" />
<bean id="rcf" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="${rabbitmq.host}"/>
<property name="requestedHeartbeat" value="10" />
</bean>
You should use requestedHeartbeat property for connectionfacory bean
<bean id="rabbitconnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost"/>
<property name="requestedHeartbeat" value="100" />
</bean>