Configure multiple instances of ActiveMq listeners on multiple JVM's - spring

I want to configure multiple instances of ActiveMQ listeners on multiple JVM's(there is a 1-1 mapping between queues and listeners). We are separating listeners for high performance. Currently i have few options like configuring in database, spring xml and properties file. Not sure which is the best approach ... any help appreciated. Thanks.

configuring ActiveMQ listeners via Spring's MessagListenerContainer in Spring XML is the standard approach
see this page for more details: http://activemq.apache.org/spring-support.html

you can create multiple instance of ActiveMQ, use the following steps.
Go to your activemq directory bin folder and run the below commands
Create the Instance 1
cd /apache-activemq-5.8.0/bin
./activemq create instance1
./activemq setup ~/.activemqrc-instance-instance1
ln -s /home/[yourHomeDir]/.activemqrc-instance-instance1
Create the Instance 2
./activemq create instance2
./activemq setup ~/.activemqrc-instance-instance2
ln -s /home/[yourHomeDir]/.activemqrc-instance-instance2
Once above commands are executed, go to the instance2 conf and change the default port for the openwire, amqp in the activemq.xml and also change the Connector in jetty.xml.
You can start each instance as below.
cd apache-activemq-5.8.0/bin/instance1/bin
./instance1 console
Open a new Tab
cd apache-activemq-5.8.0/bin/instance2/bin
./instance2 console

Related

How do I create multiple tasks in Kafka Source Connector?

I'm new to Apache Kafka and I'm trying to create multiple tasks, each one with a separate purpose. But the source connector method taskClass() returns only 1 task class. So how do I create more ?
Deploy multiple connector instances, using the plugin you require. You have gone too low-level looking at taskClass() etc. If you can't get the data from multiple sources with a single connector configuration, just create additional connector configurations. Each is just config files. One connector = one task (or more, if scaled out).

Asynchronous task execution using Spring in container managed environment

I want to run few tasks asynchronously in a web application. My question is which Spring implementation of task executors i should use in a Container managed environment.
I refereed to this chapter in Spring documentation and found few options.
One option I considered is WorkManagerTaskExecutor. This is very simple and works seamlessly with the IBM Websepher server which I'm currently using but this is very specific to IBM Websphere and Oracle Weblogic servers. I don't want to tie my code specifically to one particular implementation as in some test and local regions we are using Jetty container & this implementation creates problems to run the code in Jetty.
Other options like SimpleThreadPoolTaskExecutor does not seem to be best fit to leverage thread pooling in container managed environment and I don't want to create new thread myself.
Could you pleas suggest how do I go about this. Any pointers to a sample implementation will be great help.
As usual, it depends. If you rely on the container's thread management and want to be able to set thread pools on its admin interface or if you're application is not the only app inside the container or you use specific features like setting thread pool priorities for EJB or JMS you should add support for the WorkManagerTaskExecutor and make it configurable. If not, you can use whatever you want cause in the end threads are just threads. Since Spring is an IOC container you can do it. To use the same app everywhere I wouldn't suggest to change the XML config per app version. Rather
use profiles with configuration to set the executor type and inside your java config return the proper bean type. If you use Jetty you should have a configuration for the thread pool sizes to to be able to tune it.
use spring boot like auto configuration which usually rely on available classes on classpath (#ConditionalOnClass). If your weblogic or websphere specific classes are available or any other container specific thing like env variables you can create the WorkManagerTaskExecutor
With both of these you can deploy the same war everywhere.

How to specify JDBC setting in a struts project?

I am trying to setup a struts project locally. One way I know to set up JDBC settings as to go to administrative console of websphere and create JDBC provider and JNDI and all. But is there any other way to do in the code itself?
There is some resource reference in web.xml. I am totally new to struts.Please help.
DataSourceAlias
javaxsql.Data...... etc etc
If you configured for WAS 6.1and configuration is good you need to stop and start nodeAgents for the changes to get propagated and test the jdbc connection after restarting.....if it was WAS 8 they will be propagated automatically that means you configured improperly

Publishing messages on HornetQ using JMeter

I'm developing a project wich is using HornetQ, and I want to publish some messages on it to execute a load test using JMeter. Does anyone here ever tried anything like it?
How can I configure JMeter to publish messages on HornetQ?
I already copied all the jars to the JMeter lib and filled all the fields on the "JMS Publisher Sampler". How can I proceed? Any example or JMX file which I could use as an example?
Add HornetQ JARs to jmeter/lib folder
Then for configuration of JMS Sampler use this:
http://docs.jboss.org/hornetq/2.2.5.Final/user-manual/en/html/using-jms.html

Can I use Spring Integration as a daemon in order to poll a directory?

I am new to Spring Integration and I am considering using it in order to poll a directory for new files in order to process those files.
My question is: is Spring Integration some sort of daemon one can launch and that one can use in order to poll a directory?
Is this is possible can someone please direct me to relevant section of the official documentation on how to launch Spring Integration?
All you need is to have a main method (or a WAR file if you want to deploy to Tomcat or another servlet container) that creates a Spring ApplicationContext (e.g. new ClassPathXmlApplicationContext("file-poller.xml"))
It can run with a cron trigger, fixed-rate or fixed-delay trigger.
JMX operations can be exposed on Spring Integration's File adapter (or any adapter) by simply adding a single config element (e.g. <mbean-export>).
Bottom line: you REALLY do not need an ESB if you simply want a File poller to run continuously. You can have a single small config file and one line of code in a main method.
Visit the samples for more info: https://github.com/springsource/spring-integration-samples (look under basic/file specifically)
Hope that helps,
Mark
Spring Integration is a part of framework, its not a programm or daemon.
What you cant do — is to configure Spring Integration to poll a directory, lunch JVM with Spring onboard and poller will do what you want.
You can start with this blog post.
More samples
Relevant section of documentation

Resources