How to configuration Oracle connection pool in ActiveMQ - 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>

Related

Ignite backups=1 works incorrectly

I am using pure in-memory ignite on k8s. There are 3 instances with backups=1 as the config below. I tried to restart one instance to see if it will be re-fill after restarting but the size of all other instances was reduced instead of re-filling the restarted one.
Size of Ignite cache
my config
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="groupName" value="bi_user_mask"/>
<property name="name" value="dmp_user_mask"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="partitionLossPolicy" value="IGNORE"/>
<property name="backups" value="1"/>
<property name="onheapCacheEnabled" value="true"/>
<property name="evictionPolicyFactory">
<bean class="org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicyFactory">
<property name="maxMemorySize" value="#{512L * 1024 * 1024}"/>
<property name="batchSize" value="1024"/>
<property name="maxSize" value="#{100L * 1024 * 1024}"/>
<property name="comp" ref="sorted_value_eviction"/>
</bean>
</property>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<property name="eagerTtl" value="false"/>
<property name="expiryPolicyFactory">
<bean class="javax.cache.expiry.TouchedExpiryPolicy" factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="DAYS"/>
<constructor-arg value="10"/>
</bean>
</constructor-arg>
</bean>
</property>
<property name="statisticsEnabled" value="true"/>
</bean>
Is there anyone have an idea to fix it?
Thank you

Enable SSL in ActiveMQ - connection getting timed out while accessing web console over https

I have a RHEL 7 server where I have ActiveMQ installed (version : apache-activemq-5.15.11).I am trying to run the web console over https and hence I went through the instructions mentioned in the documentation here and made changes in my jetty.xml and un-commented the following section:
<!--
Enable this connector if you wish to use https with web console
-->
<!-- bean id="SecureConnector" class="org.eclipse.jetty.server.ServerConnector">
<constructor-arg ref="Server" />
<constructor-arg>
<bean id="handlers" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<property name="keyStorePath" value="${activemq.conf}/broker.ks" />
<property name="keyStorePassword" value="password" />
</bean>
</constructor-arg>
<property name="port" value="8162" />
</bean -->
when I am trying to access the web console like the following:
https://myserver.com:8162/admin/index.jsp
I am getting connection getting timed out in the browser.
Questions :
Am I trying to access it properly - via port 8162? It works fine with port 8161 and over http like the following:
http://myserver.com:8161/admin/index.jsp
Are there any additional changes needed to make it work over https?
My jetty.xml is below for reference:
<!--
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to You under
the Apache License, Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or
agreed to in writing, software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
An embedded servlet engine for serving up the Admin consoles, REST and Ajax APIs and
some demos Include this file in your configuration to enable ActiveMQ web components
e.g. <import resource="jetty.xml"/>
-->
<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 id="securityLoginService" class="org.eclipse.jetty.security.HashLoginService">
<property name="name" value="ActiveMQRealm" />
<property name="config" value="${activemq.conf}/jetty-realm.properties" />
</bean>
<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC" />
<property name="roles" value="user,admin" />
<!-- set authenticate=false to disable login -->
<property name="authenticate" value="true" />
</bean>
<bean id="adminSecurityConstraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC" />
<property name="roles" value="admin" />
<!-- set authenticate=false to disable login -->
<property name="authenticate" value="true" />
</bean>
<bean id="securityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="securityConstraint" />
<property name="pathSpec" value="/api/*,/admin/*,*.jsp" />
</bean>
<bean id="adminSecurityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="adminSecurityConstraint" />
<property name="pathSpec" value="*.action" />
</bean>
<bean id="rewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<property name="rules">
<list>
<bean id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
<property name="pattern" value="*"/>
<property name="name" value="X-FRAME-OPTIONS"/>
<property name="value" value="SAMEORIGIN"/>
</bean>
<bean id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
<property name="pattern" value="*"/>
<property name="name" value="X-XSS-Protection"/>
<property name="value" value="1; mode=block"/>
</bean>
<bean id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
<property name="pattern" value="*"/>
<property name="name" value="X-Content-Type-Options"/>
<property name="value" value="nosniff"/>
</bean>
</list>
</property>
</bean>
<bean id="secHandlerCollection" class="org.eclipse.jetty.server.handler.HandlerCollection">
<property name="handlers">
<list>
<ref bean="rewriteHandler"/>
<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/admin" />
<property name="resourceBase" value="${activemq.home}/webapps/admin" />
<property name="logUrlOnStart" value="true" />
</bean>
<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/api" />
<property name="resourceBase" value="${activemq.home}/webapps/api" />
<property name="logUrlOnStart" value="true" />
</bean>
<bean class="org.eclipse.jetty.server.handler.ResourceHandler">
<property name="directoriesListed" value="false" />
<property name="welcomeFiles">
<list>
<value>index.html</value>
</list>
</property>
<property name="resourceBase" value="${activemq.home}/webapps/" />
</bean>
<bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler">
<property name="serveIcon" value="false" />
</bean>
</list>
</property>
</bean>
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="loginService" ref="securityLoginService" />
<property name="authenticator">
<bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
</property>
<property name="constraintMappings">
<list>
<ref bean="adminSecurityConstraintMapping" />
<ref bean="securityConstraintMapping" />
</list>
</property>
<property name="handler" ref="secHandlerCollection" />
</bean>
<bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
</bean>
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
<!-- the default port number for the web console -->
<property name="host" value="0.0.0.0"/>
<property name="port" value="8161"/>
</bean>
<bean id="Server" depends-on="jettyPort" class="org.eclipse.jetty.server.Server"
destroy-method="stop">
<property name="handler">
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<property name="handlers">
<list>
<ref bean="contexts" />
<ref bean="securityHandler" />
</list>
</property>
</bean>
</property>
</bean>
<bean id="invokeConnectors" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="Server" />
<property name="targetMethod" value="setConnectors" />
<property name="arguments">
<list>
<bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
<constructor-arg ref="Server" />
<!-- see the jettyPort bean -->
<property name="host" value="#{systemProperties['jetty.host']}" />
<property name="port" value="#{systemProperties['jetty.port']}" />
</bean>
<!--
Enable this connector if you wish to use https with web console
-->
<!-- Enabling the following connector on Nov 11,2020 for HTTPS -->
<bean id="SecureConnector" class="org.eclipse.jetty.server.ServerConnector">
<constructor-arg ref="Server" />
<constructor-arg>
<bean id="handlers" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<property name="keyStorePath" value="${activemq.conf}/broker.ks" />
<property name="keyStorePassword" value="password" />
</bean>
</constructor-arg>
<property name="port" value="8162" />
</bean>
</list>
</property>
</bean>
<bean id="configureJetty" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="org.apache.activemq.web.config.JspConfigurer.configureJetty" />
<property name="arguments">
<list>
<ref bean="Server" />
<ref bean="secHandlerCollection" />
</list>
</property>
</bean>
<bean id="invokeStart" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
depends-on="configureJetty, invokeConnectors">
<property name="targetObject" ref="Server" />
<property name="targetMethod" value="start" />
</bean>
</beans>

Ignite with No eviction

In Ignite cache we are not able to store more than 1 Million records. Records are getting evicted whenever the count is more than 1 Million.
Ignite Configuration
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="maxSize" value="#{30L * 1024 * 1024 * 1024}"/>
<property name="name" value="500MB_Region"/>
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
<property name="clientMode" value="false"/>
<property name="peerClassLoadingEnabled" value="true"/>
<property name="networkTimeout" value="10000000"/>
<property name="networkSendRetryCount" value="50"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>cluster.node.host1:47500</value>
<value>cluster.node.host2:47500</value>
<value>cluster.node.host3:47500</value>
<value>cluster.node.host4:47500</value>
<value>cluster.node.host5:47500</value>
</list>
</property>
</bean>
</property>
<property name="networkTimeout" value="10000000"/>
<property name="joinTimeout" value="10000000"/>
<property name="maxAckTimeout" value="10000000"/>
<property name="reconnectCount" value="50"/>
<property name="socketTimeout" value="10000000"/>
</bean>
</property>
</bean>
</beans>
Cache configuration:
var cache: CacheConfiguration[Long, String] = new CacheConfiguration[Long, String]("NAME_CACHE")
cache.setCacheMode(CacheMode.PARTITIONED)
cache.setBackups(0)
cache.setOnheapCacheEnabled(true)
cache.setDataRegionName("500MB_Region")
We need the cache to store data upto 30 GB and move to Ignite native persistence when it exceeds the size. There should be no data eviction.
Thanks in Advance !!!

Not able to find database while joining 2 cache in ignite

I am working on utilizing distributed joins between multiple ignite cache. I loaded the required data in both the caches and while performing the join it fails while parsing the SQL suggesting "Database not found" (Please see the stack trace).
Caused by: org.h2.jdbc.JdbcSQLException: Database "OFFER" not found; SQL statement:
SELECT "customOrganizationCache".Organization._key, "customOrganizationCache".Organization._val from Organization as organization, "customOfferCache".Offer as offer where organization._id = offer.relationships.customer.targets.key and organization._id = ? [90013-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
Below is my ignite config file:
<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 id="offerCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomOfferCacheStore</value></constructor-arg>
</bean>
<bean id="organizationCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomOrganizationCacheStore</value></constructor-arg>
</bean>
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="false"/>
<property name="clientMode" value="false"/>
<property name="gridName" value="clusterGrid"/>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="name" value="customOrganizationCache"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeBehindEnabled" value="true"/>
<property name="copyOnRead" value="false"/>
<property name="memoryMode" value="OFFHEAP_TIERED"/>
<property name="atomicWriteOrderMode" value="PRIMARY"/>
<property name="indexedTypes" >
<list>
<value>java.lang.String</value>
<value>com.xyz.exploreignite.pojo.Organization</value>
</list>
</property>
<!-- Cache store. -->
<property name="cacheStoreFactory" ref="organizationCacheStoreFactory"/>
<property name="swapEnabled" value="false"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="evictionPolicy">
<!-- LRU eviction policy. -->
<bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
<!-- Set the maximum cache size to 1 million (default is 100,000). -->
<property name="maxSize" value="1000000"/>
</bean>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="name" value="customOfferCache"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeBehindEnabled" value="true"/>
<property name="copyOnRead" value="false"/>
<property name="memoryMode" value="OFFHEAP_TIERED"/>
<property name="atomicWriteOrderMode" value="PRIMARY"/>
<property name="indexedTypes" >
<list>
<value>java.lang.String</value>
<value>com.xyz.exploreignite.pojo.Offer</value>
</list>
</property>
<!-- Cache store. -->
<property name="cacheStoreFactory" ref="offerCacheStoreFactory"/>
<property name="swapEnabled" value="false"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="evictionPolicy">
<!-- LRU eviction policy. -->
<bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
<!-- Set the maximum cache size to 1 million (default is 100,000). -->
<property name="maxSize" value="1000000"/>
</bean>
</property>
</bean>
</list>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
Below is the code that I am using while performing the join:
try (Ignite ignite = Ignition.start(
// "/home/impadmin/ignite/apache-ignite-fabric-1.7.0-bin/examples/config/example-cache-ss-cluster.xml"))
// {
"/home/xyz/msheth/install/apache-ignite-fabric-1.7.0-bin/examples/config/example-cache-ss-cluster.xml")) {
try (IgniteCache<String, Offer> customOfferCache = ignite.getOrCreateCache("customOfferCache");
IgniteCache<String, Organization> customOrganizationCache = ignite
.getOrCreateCache("customOrganizationCache")) {
SqlFieldsQuery joinQuery = new SqlFieldsQuery("select organization.displayName "
+ "from Organization as organization, \"customOfferCache\".Offer as offer"
+ " where organization._id = offer.relationships.customer.targets.key "
+ "and organization._id = ?");
joinQuery.setDistributedJoins(true);
long startTime = System.currentTimeMillis();
try (QueryCursor<List<?>> joinCursor = customOrganizationCache
.query(joinQuery.setArgs("542de0b83b2d445f0a0e0f53"))) {
for (List<?> organizationEntry : joinCursor)
System.out.println("Organizations display name: " + organizationEntry);
}
System.out.println("Time to fetch join based record:" + (System.currentTimeMillis() - startTime));
}
}
Please help me to find the root cause.
The issue is in this expression:
offer.relationships.customer.targets.key
Couple of considerations around this:
You are allowed to have nested objects, however Ignite will create flat schema. E.g., customer field can be accessed as a member of Offer table, you should not provide this full path for this. Generally, you should try to avoid nested object when using SQL and create simple POJO classes instead.
However, you are not allowed to query inside a collection. In your case the whole collection of targets is saved as a single object and you can't select based on its contents. You should have separate cache for Target objects and join it with other tables.

My jasig don't use the User ldap password

We have several services auntentican with an LDAP server, we put JASIG as the main entrance, we deploy JASIG on Jboss7 and works well over SSL, however our LDAP server over TLS works. My problem is that over TLS for any authenticated user runs any user password, right or wrong.
I do not know why the login username is sensitive and not sensitive to the password, pass any password.
Thank you.
Show parts interesting parts of my DeployConfigContex.xml file.
This is our AuthenticationManager:
<bean id="authenticationManager"
class="org.jasig.cas.authentication.AuthenticationManagerImpl">
<property name="credentialsToPrincipalResolvers">
<list>
<bean
class="org.jasig.cas.authentication.principal.CredentialsToLDAPAttributePrincipalResolver">
<property name="credentialsToPrincipalResolver">
<bean
class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" />
</property>
<property name="filter" value="(cn=%u)" />
<property name="principalAttributeName" value="cn" />
<property name="searchBase" value="ou=ServiciosCentrales,ou=Usuarios,dc=educacion,dc=es" />
<property name="contextSource" ref="contextSource" />
<property name="attributeRepository">
<ref bean="attributeRepository" />
</property>
</bean>
</list>
</property>
<property name="authenticationHandlers">
<list>
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" />
<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">
<property name="filter" value="cn=%u" />
<property name="searchBase" value="ou=ServiciosCentrales,ou=Usuarios,dc=educacion,dc=es" />
<property name="contextSource" ref="contextSource" />
<property name="ignorePartialResultException" value="yes" />
</bean>
</list>
</property>
</bean>
this es our contexsource:
<property name="pooled" value="false" />
<property name="userDn" value="cn=secret,dc=educacion,dc=es"/>
<property name="password" value="secret"/>
<property name="url" value="ldap://192.168.0.100:389"/>
<qualifier value="secured"/>
<property name="authenticationStrategy">
<bean class="org.springframework.ldap.core.support.DefaultTlsDirContextAuthenticationStrategy">
<property name="sslSocketFactory">
<bean class="com.cein.educa.ldap.LDAPSocketFactory" />
</property>
<property name="hostnameVerifier">
<bean class="com.cein.educa.ldap.LDAPHostNameVerifier" />
</property>
<property name="shutdownTlsGracefully" value="true" />
</bean>
</property>
<property name="baseEnvironmentProperties">
<map>
<entry key="java.naming.security.authentication" value="simple" />
</map>
</property>
</bean>