The goal is to create a clustered environment for a web application that is currently running in a single Jetty instance. When clustering configuration is added, it appears to prevent the applications data source pool from initializing. Attaching a remote debugging session and stepping through the code shows the application hanging on startup while waiting for a connection to free up from the pool. Inspecting the details of the pool shows no connections have been created. c3p0 is used for the pooling implementation. When the server starts without the clustering configuration, c3p0 generates a log message showing it is initializing. When started with clustering configured, the log message is not seen. Leading me to believe the application data source pool is never initialized because the clustering data source pool is usurping it in some way.
To get the clustering behavior I added the following to %JETTY_HOME%/etc/jetty.xml.
<New id="DSClustering" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/DSClustering</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="driverClass">oracle.jdbc.OracleDriver</Set>
<Set name="jdbcUrl">jdbc:oracle:thin:#xxxxx:1521:xe</Set>
<Set name="User">xxxx</Set>
<Set name="Password">xxxx</Set>
</New>
</Arg>
</New>
<Set name="sessionIdManager">
<New id="jdbcidmgr" class="org.eclipse.jetty.server.session.JDBCSessionIdManager">
<Arg><Ref id="Server"/></Arg>
<Set name="workerName">jetty1</Set>
<Set name="DatasourceName">jdbc/DSClustering</Set>
<Set name="scavengeInterval">60</Set>
</New>
</Set>
<Call name="setAttribute">
<Arg>jdbcIdMgr</Arg>
<Arg><Ref id="jdbcidmgr"/></Arg>
</Call>
And added the following to the applications jetty-web.xml
<Set name="sessionHandler">
<New class="org.eclipse.jetty.server.session.SessionHandler">
<Arg>
<New class="org.eclipse.jetty.server.session.JDBCSessionManager">
<Set name="idManager">
<Ref id="jdbcidmgr"/>
</Set>
</New>
</Arg>
</New>
</Set>
The applications data source pool is configured as a Spring bean -
<bean id="sysContextAwareDataSource" class="com.mycompany.datasource.SysContextAwareDataSource">
<property name="targetDataSource" ref="myPoolDataSource"/>
<property name="connectionWaitLoggingThreshold" value="1000"/>
</bean>
<bean id="myPoolDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="acquireIncrement" value="${jdbc.pool.acquireIncrement}"/>
<property name="minPoolSize" value="${jdbc.pool.minPoolSize}"/>
<property name="maxPoolSize" value="${jdbc.pool.maxPoolSize}"/>
<property name="initialPoolSize" value="${jdbc.pool.initialPoolSize}"/>
<property name="acquireRetryAttempts" value="${jdbc.pool.acquireRetryAttempts}"/>
<property name="testConnectionOnCheckin" value="${jdbc.pool.testConnectionOnCheckin}"/>
<property name="idleConnectionTestPeriod" value="${jdbc.pool.idleConnectionTestPeriod}"/>
<property name="preferredTestQuery" value="${jdbc.pool.preferredTestQuery}"/>
<property name="maxIdleTime" value="${jdbc.pool.maxIdleTime}"/>
<property name="acquireRetryDelay" value="${jdbc.pool.acquireRetryDelay}"/>
<property name="maxStatements" value="${jdbc.pool.maxStatements}"/>
<property name="maxStatementsPerConnection" value="${jdbc.pool.maxStatementsPerConnection}"/>
</bean>
<bean id="userDAO" class="com.mycompany.dataaccess.UserDAOImpl">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="dataSource" ref="transactionAwareDataSourceProxy"/>
</bean>
Environment: jetty 8.1.9, Oracle 11g, Windows 7 Enterprise, JDK 1.6.0_38
Figured it out! This was caused because I had 2 ojdbc-10.2.0.4.0.jars that were being accessed. To get the session management DB implementation working I added an ojdbc jar to JETTY_HOME\lib\ext. This provided the Oracle classes to the Jetty server. There’s also a ojdbc jar contained in the applications lib directory, which is used by the application. The problem occurred because the ojdbc jar is a “sealed” jar. Meaning, once a class is loaded from one of the jars, an attempt to load the same class from another jar causes a security exception to be thrown. So the Jetty server would load an Oracle class from the lib/ext version of the jar. Then the application would try to load the same class from its ojdbc jar, causing the security exception. It took a while to figure out because the c3p0 class that received the exception, silently swallowed the exception and then tried to establish the connection again. This was happening on another thread then the one I was looking at. That was the thread that was establishing connections for the pool, while I was looking at the thread that was waiting for connections from the pool. Argh!
Related
I created an AKS and I deployed the Apache Ignite service on it.
When I check the pods I can see they are working.
Also, I can get the load balancer IP.
I follow the official instructions of Apache and try to connect Ignite with ThinClient.
I share my code and instructions code.
Here is my code:
public void ConnectIgnite()
{
var cfg = new IgniteClientConfiguration
{
Endpoints = new[] { "20.101.12.***:10800" }
};
var client = Ignition.StartClient(cfg);
}
But my code is getting below errors;
System.AggregateException: 'Failed to establish Ignite thin client
connection, examine inner exceptions for details.'
Inner Exception ExtendedSocketException: A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond.
and here is the Apache's instruction code;
ClientConfiguration cfg = new ClientConfiguration().setAddresses("13.86.186.145:10800");
IgniteClient client = Ignition.startClient(cfg);
ClientCache<Integer, String> cache = client.getOrCreateCache("test_cache");
cache.put(1, "first test value");
System.out.println(cache.get(1));
client.close();
Also, here is the official instruction link
I didn't understand what is wrong? Also, The Instruction says I don't need clientid and clientsecret but I don't want to connect without any security but this is completely another issue.
I found what is wrong. Apache's official page says: use below XML for the configuration.
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
<constructor-arg>
<bean class="org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration">
<property name="namespace" value="default" />
<property name="serviceName" value="ignite" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
but,
first, that XML needs a beans tag at the top of XML.
Also, namespace value and serviceName value are not compatible with apache's official instruction page. If you follow the apache's page for the setup;
you have to use the below values
<property name="namespace" value="ignite" />
<property name="serviceName" value="ignite-service" />
instead of
<property name="namespace" value="default" />
<property name="serviceName" value="ignite" />
end of the changes your XML will look like
<?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">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
<constructor-arg>
<bean class="org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration">
<property name="namespace" value="ignite" />
<property name="serviceName" value="ignite-service" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
I changed my configuration XML and restart the pods with below command and It worked.
kubectl -n service rollout restart deployment ignite-cluster
Try connecting using 20.101.12.*** address from the outside.
Btw, what is 13.86.186.145, why are you trying to connect to it?
An update:
Seems like you just copy-pasted it from the docs, you need to replace it with your own values.
I am using jms:outbound-channel-adapter.
We noticed that application server is starting way too many MQ connections. Application ultimately exhausts the maxChannel limit of MQ Server and starts getting :
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2537' ('MQRC_CHANNEL_NOT_AVAILABLE')
I am using MQTopicConnectionFactory, CachingConnectionFactory, outbound-channel-adapter.
Current configuration:
<bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQTopicConnectionFactory">
<property name="SSLCipherSuite" value="${mq.sslCipherSuite}"/>
<property name="hostName" value="${mq.hostName}"/>
<property name="port" value="${mq.port}"/>
<property name="channel" value="${mq.channel}"/>
<property name="transportType" value="1"/>
</bean>
<bean id="cachedConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory"
p:targetConnectionFactory-ref="jmsTConnectionFactory"
p:reconnectOnException="true" p:sessionCacheSize="10"
p:cacheProducers="true" />
<bean id="senderTopic" class="com.ibm.mq.jms.MQTopic" >
<constructor-arg value="${mq.topicName}"/>
</bean>
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="cachedConnectionFactory" />
</property>
<property name="defaultDestination">
<ref bean="senderTopic" />
</property>
</bean>
Outbound-channel-adapter:
<int-jms:outbound-channel-adapter
id="jmsOutToNE" channel="umpAlertNotificationJMSChannel"
destination="senderTopic" jms-template="jmsQueueTemplate">
<!-- <int:retry-advice/> -->
</int-jms:outbound-channel-adapter>
Spring integration flow having 250 concurrent threads, however, there are 2000+ MQ connections starting during peak load.
What is the significance of sessionCacheSize="10" in CachingConnectionFactory if the connections are exceeding 500?
How can I limit the MQ connections?
Can't JMS reuse the MQ connection from the a pool the way DB connections work?
I am using spring integration to connect with the IBM MQ. My spring integration application is connecting successfully with IBM MQ. Now the MQ team made the MQ manager as the clustered manager i.e. queue manager is containing 2 host one active and one passive because if one host is down the passive one will up and running.
Below is my spring integration configuration for MQ and I can pass only one host.
<bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value=""/>
<property name="port" value=""/>
<property name="channel" value=""/>
<property name="queueManager" value=""/>
<property name="transportType" value="1"/>
</bean>
Is there any way by which we can pass both the active and passive host's from the configuration. I tried with the comma in host but that is not supported .
Please suggest
You should specify the hosts under the property connectionNameList, don't use hostName and port.
http://www-01.ibm.com/support/docview.wss?uid=swg21397867
Multi Instance MQ set up
The ConnectionNameList will allow to pass the active and passive host
<bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="connectionNameList" value="activeHost(port),passiveHost(port)"/>
<property name="channel" value="channel Name"/>
<property name="queueManager" value="Queue Manager name"/>
<property name="transportType" value="transport type"/>
</bean>
I am using Spring Batch for data migration from XML to Oracle Database.
With Single Thread execution, process takes 80-90 Mins to insert 20K users approx.
I want to reduce it to more than half but even using Multi File Resource, I am not able to achieve that.
I have a single XML to be processed so I started simply by adding
task executor and making Reader synchronized but not able to achieve gain.
So what I am doing, I split XML into multiple XMLS and want to try with Multi File Resource. Here is the configuration.
<batch:job id="importJob">
<batch:step id="step1Master">
<batch:partition handler="handler" partitioner="partitioner" />
</batch:step>
</batch:job>
<bean id="handler"
class="org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler">
<property name="taskExecutor" ref="taskExecutor" />
<property name="step" ref="slaveStep" />
<property name="gridSize" value="20" />
</bean>
<batch:step id="slaveStep">
<batch:tasklet transaction-manager="transactionManager"
allow-start-if-complete="true">
<batch:chunk reader="reader" writer="writer"
processor="processor" commit-interval="1000" skip-limit="1500000">
<batch:skippable-exception-classes>
<batch:include class="java.lang.Exception" />
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
</batch:step>
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="100" />
<property name="maxPoolSize" value="300" />
<property name="allowCoreThreadTimeOut" value="true" />
</bean>
<bean id="partitioner"
class="org.springframework.batch.core.partition.support.MultiResourcePartitioner"
scope="step">
<property name="keyName" value="inputFile" />
<property name="resources"
value="file:/.../*.xml" />
</bean>
<bean id="processor"
class="...Processor"
scope="step" />
<bean id="reader" class="org.springframework.batch.item.xml.StaxEventItemReader"
scope="step">
<property name="fragmentRootElementName" value="user" />
<property name="unmarshaller" ref="userDetailUnmarshaller" />
<property name="resource" value="#{stepExecutionContext[inputFile]}" />
</bean>
My Single XML file contains users around 1000 and I am trying by having 20 files.
I kept commit-interval=1000 as each file has 1000 records to be insert in DB.
Do commit-interval needs to adjusted accordingly?
I am using ORACLE DB, Do I need to do any pool management there.
Current Pool of ORACLE DB configured in JBOSS
Min Pool = 100
Max Pool = 300
I see logging like
17:01:50,553 DEBUG [Writer] (taskExecutor-11) [UserDetailWriter] | user added
17:01:50,683 DEBUG [Writer] (taskExecutor-15) [UserDetailWriter] | user added
17:01:51,093 DEBUG [Writer] (taskExecutor-11) [UserDetailWriter] | user added
17:01:59,795 DEBUG [Writer] (taskExecutor-12) [UserDetailWriter] | user added
17:02:00,385 DEBUG [Writer] (taskExecutor-12) [UserDetailWriter] | user added
17:02:00,385 DEBUG [Writer] (taskExecutor-12) [UserDetailWriter] | user added
It seems multiple threads are being created but still I am not seeing any performance improvement here?
Please suggest what I am doing wrong?
go through this documentation for parallel processing
http://docs.spring.io/spring-batch/trunk/reference/html/scalability.html#scalabilityParallelSteps
I am trying to Hazelcast 3.2.4 Management Center to start up in TC Server 3.2.4 Tomcat 7. But even though it seems to start without errors in the logs, I can't access the page:
In Tomcat.log I can see
Line 203004: INFO: Deploying web application archive /vc2cmmkb019231n/app/pm13/process-1.3-build317/instances/vm1/webapps/mancenter-3.2.4.war
Line 203016: INFO: notifyApplicationLifecycle(localhost|mancenter-3.2.4)[START]
Line 203018: WARNING: handleStartEvent(localhost|mancenter-3.2.4)[START] failed (ConnectException) to send ping: No current registered listener
Line 204206: INFO: notifyApplicationLifecycle(localhost|mancenter-3.2.4)[STOP]
that indicates that mancenter has started and stopped, but when I try to access the web page:
http://my-host-name:8080/mancenter-3.2.4/
it doesn't load up.
I am using the following hazelcast spring configuration:
<bean id="hcMonitorInstance" class="com.hazelcast.core.Hazelcast" destroy-method="shutdown" factory-method="newHazelcastInstance">
<constructor-arg>
<bean class="com.hazelcast.config.Config">
<property name="instanceName" value="hcMonitorInstanceConfig"/>
<property name="groupConfig">
<bean class="com.hazelcast.config.GroupConfig">
<property name="name" value="${px-monitor-monitor.com.hazelcast.config.GroupConfig.name}"/>
<property name="password" value="${px-monitor-monitor.com.com.hazelcast.config.GroupConfig.password}"/>
</bean>
</property>
<property name="networkConfig">
<bean class="com.hazelcast.config.NetworkConfig">
<property name="join" ref="join"/>
<property name="port" value="${px-monitor-monitor.hazelcastInstanceConfig.port}"/>
<property name="portAutoIncrement" value="true"/> <!--THIS is FALSE in CIWS-->
<property name="interfaces">
<bean class="com.hazelcast.config.InterfacesConfig">
<property name="interfaces">
<list>
<value>*</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="managementCenterConfig">
<bean class="com.hazelcast.config.ManagementCenterConfig">
<property name="enabled" value="${hz.management.center.enabled}"/>
<property name="url" value="${hz.management.center.url}"/>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
Any Ideas on why it won't start up? I have also looked in Catalina.out for errors, but none show up. I've also tried hitting http://my-host:8080/mancenter/ but that doesn't work either. I can see the web app expanded in tomcat webapps folder and it looks to be correct.
Run java -version. If it is 1.8.0_91 then that's the culprit. Following is what you do
point to an older version of java (1.6 or 1.7 are fine) executable to run the mancenter; something similar to java -jar mancenter-3.6.2.war 8200 mancenter; I ran it on port 8200 so as to not conflict with existing app running on 8080
that should bring up the mancenter; create the admin user
now you should be able to start your 'normal' java version (1.8.0_91 most likely)
It appears the problem occurs with java 1.8.0_91 when no user has been created. Let me know if this worked.