What is the easiest way to clone messages on acitivemq queues for replay? - clone

Ideally we could apply configuration that would duplicate all messages arriving on one queue to a second queue for later replay.

You can use the camel xml configuration and apply the wire-tap pattern
you may use this pattern to log, clone, or even send your messages in a repository (let's say file repository)
There should be an already demo of Apache camel XML configuration at the /conf/ directory of your activeMQ
Cheers!

Related

Using multiple file suppliers in Spring Cloud Stream

I have an application with file-supplier Srping Cloud module included. My workflow is like track file creating/modifying in particular directory->push events to Kafka topic if there are such events. FileSupplierConfiguration is used to configure this file supplier. But now I have to track one more directory and push events to another relevant Kafka topic. So, there is an issue, because there is no possibility to include multiple FileSupplierConfiguration in project for configuration another file supplier. I remember that one of the main principles of microservices for which spring-cloud-stream was designed for is you do one thing and do it well without affecting others, but it still the same microservice with same tracking/pushing functionality but for another directory and topic. Is there any possibility to add one more file supplier with relevant configuration with file-supplier module? Or is the best solution for this issue to run one more application instance with another configuration?
Yes, the best way is to have another instance of this application, but with its own specific configuration properties. This is really how these functions have been designed: microservice based on the convention on configuration. What you are asking really contradicts with Spring Boot expectations. Imaging you'd need to connect to several data bases. So, you only can have a single JdbcTemplate auto-configured. The rest is only possible manually. But better to have the same code base which relies on the auto-configuration and may apply different props.

Apache camel read directory and get file contents

I would like to read directory with specific file path and get the file contents with apache camel and spring boot. I have router and processor class in Java. There are not many resources on the Internet, but only on the official website of apache camel. Thank you in advance.
One option is to use the Apache Camel File component to consume files. One thing to keep in mind however is that if you're deploying in a clustered environment, extra precautions need to be taken to avoid competing consumer issue. From the documentation:
Warning: most of the read lock strategies are not suitable for use in clustered mode. That is, you cannot have multiple consumers attempting to read the same file in the same directory. In this case, the read locks will not function reliably. The idempotent read lock supports clustered reliably if you use a cluster aware idempotent repository implementation such as from Hazelcast Component or Infinispan.
Because of this and other complexities, I typically avoid using the Camel file component for consuming files and just use java.nio.file.Files API in a bean/processor as it is more straightforward and provides easier mechanisms for dealing with this and other limitations.

Dependency jar for intercepting and writing rabbitmq messages to DB

Is it possible to:
Create a jar which has AOP annotation(custom) for intercepting rabbitmq listener to write the message to DB.
Pass this jar around as dependency to other spring based applications to get their messages in the DB.
Need clarifications:
1. How do we read the method argument, message here?
2. Can pointcut be read from properties so that any application using it provides its own pointcut by adding a property in like application.properties
3. Is there any special consideration about when the jar will be loaded so that the functionality is available as soon as the application starts?

Fetch file as byte array in spring integration

I'm new to spring integration. I need to fetch some file via sftp and immediately start some processing on the content of that file. There is SFTP Inbound Channel Adapter that partially satisfy me. But it saves(as documentation says) fetched file in local directory. I have no possibility to save it on local machine, but just want to start processing the content of that file, so it will be good for me to retrieve remote file as byte array or as InputStream. How can I achieve this with spring integration?
Also I want to configure my system to periodically fetch that file. I know that I can configure spring bean with #Scheduled annotation on some method and start processing from that method. But, maybe, spring integration has more elegant solution for such case?
Spring Integration 3.0.1 has a new RemoteFileTemplate that you can use to programmatically receive a file as a stream. See the Javadocs.

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

Resources