ActiveMQ nonBlockingRedelivery broker/Spring configuration - spring

I can't get the nonBlockingRedelivery property to actually work, and I can't figure out why. I must be missing something obvious.
If I try to set it up through the broker URL, for example;
tcp://localhost:61616?jms.nonBlockingRedelivery=true
I will get the following error.
Cause: Could not create Transport. Reason:
java.lang.IllegalArgumentException: Invalid connect parameters:
{jms.nonBlockingRedelivery=true}
If I try to set it up through Spring configuration, I will get the following error.
<bean id="connectionFactoryRedelivery" class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${more.MQ.brokerURL}" />
<property name="nonBlockingRedelivery" value="true" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
</bean>
</property>
<property name="synchedLocalTransactionAllowed" value="true" />
</bean>
org.springframework.beans.NotWritablePropertyException: Invalid
property 'nonBlockingRedelivery' of bean class
[org.apache.activemq.ActiveMQConnectionFactory]: Bean property
'nonBlockingRedelivery' is not writable or has an invalid setter
method. Does the parameter type of the setter match the return type of
the getter?

My retarded error, I was using an old version of the JAR where this property actually did not exist. The above Spring configuration works 100%, and if you're having problems, they lie somewhere else.

I believe that I'm still seeing this issue with spring-boot-starter-activemq:1.5.10.RELEASE - in that this on spring.activemq.broker-url does not work:
?jms.nonBlockingRedelivery=true
However setting this property fixes it:
spring.activemq.non-blocking-redelivery: true

Related

After Spring upgrade from 5.2.x to 5.3.x - No mapping for GET

After upgrade from Spring 5.2.x to 5.3.x, the error message DispatcherServlet.noHandlerFound Message=No mapping for GET /sampler/
Sample code -- https://github.com/hth/sampler working fine with 5.2.12 lib
This may be related to a change where additional beans are registered with the DispatcherServlet.
Specifically, the DefaultRequestToViewNameTranslator bean is now loaded in 5.3.x, which may be transforming the URI to a view name.
You may be able to disable this behavior by setting the stripLeadingSlash, stripExtension, and stripTrailingSlash properties to false.
Try adding the following bean definition to your root-context.xml file.
<bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator">
<property name="stripLeadingSlash" value="false" />
<property name="stripExtension" value="false" />
<property name="stripTrailingSlash" value="false" />
</bean>

Configure Spring bean by setting up the elastic 5.5.1 configuration settings and create a transport client bean

I am trying to use ElasticSearch Java API 5.5.1 and while trying to create a bean for PreBuiltTransportClient(TransportClient in ES 2.3) I am facing the below issue.
Error creating bean with name 'preBuildTransportClient' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [org.elasticsearch.common.settings.Settings$Builder] to required type [org.elasticsearch.common.settings.Settings]: Failed to convert value of type [org.elasticsearch.common.settings.Settings$Builder] to required type [org.elasticsearch.common.settings.Settings]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.elasticsearch.common.settings.Settings$Builder] to required type [org.elasticsearch.common.settings.Settings]: no matching editors or conversion strategy found
<bean id="settingsBean" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<bean id="builderObj" class="org.elasticsearch.common.settings.Settings" factory-method="builder" />
</property>
<property name="targetMethod" value="put" />
<property name="arguments">
<map>
<entry key="cluster.name">
<value>mycluster</value>
</entry>
</map>
</property>
</bean>
<bean id="transportClient" class="org.elasticsearch.transport.client.PreBuiltTransportClient">
<constructor-arg name="settings" ref="esSettingsBuilderStep2" />
<constructor-arg name="plugins">
<null />
</constructor-arg>
</bean>
Any suggestion for creating a bean for PreBuiltTransportClient?
Created a class and used that as bean with proper arguments worked for me.

Can not load property file in spring-context.xml. Property file Path is given as a placeholder in dev.properties

I am loading property file in spring-context.xml and i am giving
external property file location in
${spring.profiles.active}.properties which is in classpath and using the location as a placholder in spring-context.xml. My spring-context.xml is:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="searchSystemEnvironment" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="locations" ref="propertyConfigurerFiles" />
</bean>
<bean id="propertyConfigurerFiles" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>/WEB-INF/properties/common.properties</value>
<!--In Developemnet Enviroenment it will be dev.properties-->
<value>/WEB-INF/properties/${spring.profiles.active}.properties</value>
<!--External Property File Location as a Placeholder-->
<value>${app.config.batch.location}</value>
</list>
</constructor-arg>
</bean>
And my dev.properties is:
app.config.batch.location=E:/project/properties/config.properties
My problem is that is ${app.config.batch.location} placeholder is not
resolved in spring-context.xml and its trying to load file
${app.config.batch.location} in place of
E:/project/properties/config.properties.
I hope I explained the problem well. Please help!
Thanks in Advance!!!
You need to create bean of class PropertyPlaceHolderConfigurer.
Not just some ArrayList bean. Why do you think you need this ArrayList bean?
It seems you are using spring profiles, instead of messing with initialization time property value binding what you can do is ...
1) read the property file(profile's)
/WEB-INF/properties/${spring.profiles.active}.properties
2) create a java class that can read these property values. (don't forget to use spring profiles interfacing class)
3) as you are trying to read a property file whose location is embedded in property file(step-1), object created at step-2 will give value for key <value>${app.config.batch.location}</value>
now you can load this property file using available file reader class.
4) create Properties object and access the values in it.
Note:: if any of your bean initialization depends on key-value read at step-4, do initialization manually or create your ***custom class(servlet) that get loaded before any other class (even spring's DispactherServlet).

Apache Ignite not resolving properties in configuration XML

I am looking to load a number of values into my server configuration.xml from a properties file.
However, on adding the placeholders I start getting, property cannot be resolved errors. Preferably I would like to use Jasypt, which has loaded up fine, but has the same issue, property cannot be resolved.
Sample placeholder:
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="ignite.properties"/>
</bean>
Sample Bean:
<property name="sslContextFactory">
<bean class="org.apache.ignite.ssl.SslContextFactory">
<property name="keyStoreFilePath" value="ignite.jks"/>
<property name="keyStorePassword" value="${some.password}"/>
<property name="keyStoreType" value="JKS"/>
<property name="protocol" value="TLSv1.2"/>
<property name="trustManagers">
<bean class="org.apache.ignite.ssl.SslContextFactory" factory-method="getDisabledTrustManager"/>
</property>
</bean>
</property>
Is it possible, is there a library I should have added, it otherwise runs fine if I do not use properties.
The configuration is parsed by Spring and Ignite has nothing to do with it. I believe there are two possible reasons:
Incorrect file path. Note that if the file is on the classpath, the location should be classpath:ignite.properties.
Incorrect property name.

Spring WorkManagerTaskExecutor cannot initialize in websphere

i want use Websphere work manager for executing async jobs in jee context but i have problem with creating spring WorkManager.
bean definition:
<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor"> <property name="workManagerName" value="wm/default" /> </bean>
this definition i found in websphere help. But problem is this ends with noClassDefFound. I noticed pckg org.springframework.scheduling.commonj is missing from spring-context since version 2.x.x
Is it replaced with org.springframework.jca.work.WorkManagerTaskExecutor ?
when i use this other spring class, i get error:
Caused by: org.springframework.jndi.TypeMismatchNamingException:
Object of type [class com.ibm.ws.asynchbeans.WorkManagerImpl]
available at JNDI location [wm/default] is not assignable to
[javax.resource.spi.work.WorkManager]
so whats deal here? thx
was - 7.0.0.23
spring - 3.1.2
Class org.springframework.scheduling.commonj.WorkManagerTaskExecutor resides in spring-context-support-3.1.2.RELEASE.jar
Configuration succeeds with javax.resource.spi.work.WorkManager in applicationContext-service.xml in deployment.....
In my case deployment fails for bean injection org.springframework.scheduling.commonj.WorkManagerTaskExecutor as it fails to take WorkManager JNDI Configured in Application Server.... I just replaced javax.resource.spi.work.WorkManager. And so far it is success deployment.
I yet to see application works fine with it.
<bean id="taskExecutor" class="javax.resource.spi.work.WorkManager">
<property name="workManagerName" value="wm/default" />
</bean>
In our scenario we were managed it by ThreadPoolTaskExecutor instead of WorkManagerTaskExecutor
Here is configuration that comes in ApplicationContext.xml
<!--
<bean id="rtSenderTaskExecutor"
class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName">
<value>${org.quartz.threadPool.jndi}</value>
</property>
</bean> -->
<!-- Local Thread Pool -->
<bean id="rtSenderTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="${org.quartz.threadPool.corePoolSize}" />
<property name="maxPoolSize" value="${org.quartz.threadPool.maxPoolSize}" />
<property name="queueCapacity" value="${org.quartz.threadPool.queueCapacity}" />
<property name="keepAliveSeconds" value="${org.quartz.threadPool.keepAliveSeconds}"></property>
</bean>

Resources