Camel JMS request/Reply timeouts - jms

I am trying to send request/reply a message to a remote broker from camel but the it times out. 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-broker-url}</value></property>
<property name="clientID" value=""/>
<property name="closeTimeout" value="15000"/>
<property name="copyMessageOnSend" value="true"/>
<property name="disableTimeStampsByDefault" value="false"/>
<property name="dispatchAsync" value="false"/>
<property name="objectMessageSerializationDefered" value="false"/>
<property name="optimizeAcknowledge" value="false"/>
<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="providerJMSConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="aeroProviderJMSConnectionFactory"/>
<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="aeroProviderJMSConfig"/>
</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>
<osgi:camelContext>
Why does this happen? I realised on the remote broker the number of consumers are always more than 1 even though I did not specify how many consumers it should have. Also, whene I removed the replyTo destination, the name still keep coming up on the remote broker.
Pls, is there any tool I can use to debug activemq so that I can see who is picking messages off a queue?

When doing request/reply over JMS with Camel, it uses a 20 sec default timeout. Is it that timeout you hit?
You can alter it, its the requestTimeout option
http://camel.apache.org/jms

Related

JMS Message Redelivery not working for Topic in Spring + ActiveMQ + Atomikos + JTA + Tomcat

I have following configuration in the application that works perfectly fine with queues and redelivers the messages when a RuntimeException occurs with transaction rollback as expected.
But the same configuration fails to redeliver message with topics and emits following warning message:
WARN DefaultMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'XXX_TOPIC' - trying to recover. Cause: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: One or more resources refused to commit (possibly because of a timeout in the resource - see the log for details). This transaction has been rolled back instead.
Configuration:
<bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
<!-- <property name="sendTimeout" value="1000"/> -->
<property name="redeliveryPolicy" ref="redeliveryPolicy"/>
</bean>
<!-- Atomikos Connection Factory Wrapper For Gobal Tx -->
<bean id="queueConnectionFactoryBean" class="com.atomikos.jms.AtomikosConnectionFactoryBean">
<property name="uniqueResourceName" value="amq1" />
<property name="xaConnectionFactory" ref="amqConnectionFactory" />
</bean>
<bean id="jmsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<ref bean="queueConnectionFactoryBean"/>
</property>
<property name="sessionCacheSize" value="20"/>
<property name="cacheConsumers" value="false"/>
</bean>
<bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<bean class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init"
destroy-method="close">
<property name="forceShutdown" value="false" />
</bean>
</property>
<property name="userTransaction">
<bean class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300" />
</bean>
</property>
</bean>
<!-- Topic configuration -->
<bean id="messageListener1" class="com.x.y.impl.JmsMessageListener"></bean>
<bean id="container1" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destinationName" value="XXX_TOPIC"/>
<property name="messageListener" ref="messageListener1" />
<property name="pubSubDomain" value="true" />
<property name="transactionManager" ref="jtaTransactionManager" />
<property name="concurrency" value="1" />
<property name="receiveTimeout" value="3000" />
<!-- For local session and Atomikos-->
<property name="sessionTransacted" value="true"/>
</bean>
<!-- Bean configuration -->
<bean id="messageListener2" class="com.x.y.impl.JmsMessageListener"></bean>
<bean id="container2" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destinationName" value="XXX_QUEUE"/>
<property name="messageListener" ref="messageListener2" />
<property name="pubSubDomain" value="false" />
<property name="transactionManager" ref="jtaTransactionManager" />
<property name="concurrency" value="1" />
<!-- For local session and Atomikos-->
<property name="sessionTransacted" value="true"/>
</bean>
The Spring version used is 3.1, ActiveMQ 5.14, Atomikos 4.0.6.
Please let me know if i missed any configuration for topic DMLC.

Error at Server Startup while adding ActiveMQ by replacing HornetQ

I am using Spring 4, Hibernate, and ActiveMQ using REST APIs
ActiveMQ configurations
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="connectionFactory"></property>
</bean>
<!-- Configuration for Publishing Jms Messages -->
<bean id="activeMqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
<property name="disableTimeStampsByDefault" value="true"/>
<property name="useAsyncSend" value="true"/>
<property name="nonBlockingRedelivery" value="true"/>
<property name="redeliveryPolicy" ref="redeliveryPolicy"/>
</bean>
<bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<property name="initialRedeliveryDelay" value="60000"/>
<property name="backOffMultiplier" value="3"/>
<property name="maximumRedeliveryDelay" value="60000"/>
<property name="maximumRedeliveries" value="3"/>
<property name="redeliveryDelay" value="60000"/>
<property name="useExponentialBackOff" value="true"/>
</bean>
<!--<bean id="outgoingSmsQueue" class="org.apache.activemq.command.ActiveMQQueue">
<property name="physicalName" value="queue/outgoingSmsQueue"/>
</bean>
<bean id="emailServiceQueue" class="org.apache.activemq.command.ActiveMQQueue">
<property name="physicalName" value="queue/emailServiceQueue"/>
</bean>-->
<bean id="activemqOrderQueue" class="org.apache.activemq.command.ActiveMQQueue">
<property name="physicalName" value="ActiveMQ.orderQueue"/>
</bean>
<bean id="activemqDLQ" class="org.apache.activemq.command.ActiveMQQueue">
<property name="physicalName" value="ActiveMQ.DLQ"/>
</bean>
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="activeMqConnectionFactory"/>
<property name="sessionCacheSize" value="200"/>
<property name="cacheProducers" value="true"/>
<property name="cacheConsumers" value="true"/>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="sessionTransacted" value="true"/>
<property name="deliveryPersistent" value="true"/>
<property name="explicitQosEnabled" value="true"/>
<property name="messageIdEnabled" value="false"/>
<property name="messageTimestampEnabled" value="false"/>
</bean>
<bean id="jmsProducer" class="com.mahopos.jms.JmsProducerImpl">
<property name="jmsTemplate" ref="jmsTemplate"/>
</bean>
<!-- End Configuration for Publishing Jms Messages -->
<bean id="dlqMessageListener" class="com.mahopos.jms.DlqMessageListener" autowire="byName">
</bean>
<bean id="dlqMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"
parent="baseMessageListenerContainer">
<property name="destination" ref="activemqDLQ"/>
<property name="messageListener" ref="dlqMessageListener"/>
</bean>
<bean id="baseMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"
abstract="true">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="transactionManager" ref="jmsTransactionManager"/>
<property name="concurrentConsumers" value="10"/>
<property name="maxConcurrentConsumers" value="10"/>
<property name="idleConsumerLimit" value="1"/>
<property name="receiveTimeout" value="5000"/>
<property name="idleTaskExecutionLimit" value="50"/>
<property name="cacheLevel">
<util:constant
static-field="org.springframework.jms.listener.DefaultMessageListenerContainer.CACHE_CONSUMER"/>
</property>
</bean>
<bean id="orderQueueListener" class="com.mahopos.jms.OrderQueueListener">
<property name="demoApiService" ref="demoApiService"/>
<property name="delay" value="1500"/>
</bean>
<bean id="orderQueueListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"
parent="baseMessageListenerContainer">
<property name="concurrentConsumers" value="5"/>
<property name="destination" ref="activemqOrderQueue"/>
<property name="messageListener" ref="orderQueueListener"/>
<property name="sessionTransacted" value="true"/>
</bean>
Apparently it seems that either ContextLoaderListener is initialized more than one time, but where?
The server runs successfully but the attached image is shown in Chrome (browser) and no REST call is running after server startup.
#justin Bertram, HornetQ was working previously and I replaced it with Activemq, and the application is REST base.
Issue is resolved by adding replacing the dependency from
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
to
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.22.RELEASE</version>
</dependency>
it seems issue was due to conflicting libraries

mysql clustering connection is failed through hibernate and spring

Using MySQL workbench I can connect to the cluster db without any issue. but when I use it as the connection string jdbc:mysql:loadbalance://node_ip1,node_ip2,node_ip3/cluster_db_name?loadBalanceBlacklistTimeout=5000&loadBalanceStrategy=bestResponseTime from the app it will give me an error saying connection timeout. After that I use one cluster node and try to connect to it as we connect to localhost jdbc:mysql://cluster_node1/cluster_db_name?relaxAutoCommit=true&autoReconnect=true&useUnicode=true&connectionCollation=utf8_general_ci&characterEncoding=utf8&characterSetResults=utf8 but it also gives me the same error.
Below is the applicationContext.xml code.
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${bluesky.jdbc.driver}"/>
<property name="jdbcUrl" value="${bluesky.jdbc.url}"/>
<property name="user" value="${bluesky.jdbc.username}"/>
<property name="password" value="${bluesky.jdbc.password}"/>
<property name="minPoolSize" value="${bluesky.c3p0.pool.min.size}"/>
<property name="maxPoolSize" value="${bluesky.c3p0.pool.max.size}"/>
<property name="numHelperThreads" value="${bluesky.c3p0.numHelperThreads}"/>
<property name="acquireIncrement" value="${bluesky.c3p0.acquireIncrement}"/>
<property name="acquireRetryAttempts" value="${bluesky.c3p0.acquireRetryAttempts}"/>
<property name="idleConnectionTestPeriod" value="${bluesky.c3p0.idleConnectionTestPeriod}"/>
<property name="maxIdleTime" value="${bluesky.c3p0.maxIdleTime}"/>
<property name="preferredTestQuery" value="${bluesky.c3p0.preferred.test.query}"/>
<property name="testConnectionOnCheckout" value="${bluesky.c3p0.test.connection.on.checkout}"/>
<property name="testConnectionOnCheckin" value="${bluesky.c3p0.test.connection.on.checkin}"/>
<property name="checkoutTimeout" value="${bluesky.c3p0.checkout.timeout}"/>
<property name="debugUnreturnedConnectionStackTraces" value="${bluesky.c3p0.debug.unreturned.connection.stackTraces}"/>
<property name="unreturnedConnectionTimeout" value="${bluesky.c3p0.unreturned.connection.timeout}"/>
</bean>

How to migrate from activeMQ to ibmMQ in camelContext configuration?

I am currently using AciveMQ for routing purpose. But now i need to migrate to ibmMq. Here is my camelContext.xml configuration for AciveMq. Please help me with ibmMq config..
Thanks in advance.
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
</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="jmsConnectionFactory"/>
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
<route id="*****">
<from uri="+++++++++" />
<choice>
<to uri="activemq:queue:**********"/>
</choice>
</route>
</camelContext>
Can anybody help me change all my configuration with respective to IBMmq
I am new to IBMmq :(
Here I managed to configure with ibm mq :)
<broker xmlns="http://activemq.apache.org/schema/core"
brokerName="${broker-name}"
dataDirectory="${data}"
start="false">
...
</broker>
...
<!-- Configure IBM WebSphere MQ connection factory -->
<bean id="weblogicConnectionFactory"
class="com.ibm.mq.jms.MQConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="localhost"/>
<property name="port" value="1414"/>
<property name="queueManager" value="QM_TEST"/>
</bean>
<bean id="weblogicConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="weblogicConnectionFactory"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<bean id="weblogic"
class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="weblogicConfig"/>
</bean>
Successfully :)

How to set program name in ibatis config XML?

I am attempting to set the program name to something other than "jdbc thin client" using the iBatis dao config.
From my dao XML config file:
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property name="JDBC.Driver" value="com.foo.bar.jdbc.MyOracleDriver"/>
<property name="JDBC.ConnectionURL" value="oracle.jdbc.OracleDriver&jdbc:oracle:thin:#${host}:1521:${database}"/>
<property name="JDBC.Username" value="${userName}"/>
<property name="JDBC.Password" value="${password}"/>
<property name="Pool.DefaultAutoCommit" value="false"/>
<property name="Pool.MaximumActiveConnections" value="63"/>
<property name="Pool.MaximumIdleConnections" value="10"/>
<property name="Pool.MaximumWait" value="2000"/>
<property name="Pool.ValidationQuery" value="select 1 from dual"/>
<property name="Pool.testWhileIdle" value="true"/>
<property name="Pool.TestOnBorrow" value="true"/>
<property name="Pool.LogAbandoned" value="true"/>
<property name="Pool.RemoveAbandoned" value="true"/>
<property name="Pool.RemoveAbandonedTimeout" value="300"/>
</dataSource>
</transactionManager>
I would assume this is as easy as adding the following:
<property name="v$session.program" value="My Program Name"/>
But that didn't work. The program name did not change. What am I doing wrong?

Resources