This seems to be simple but I can't work it out.
I am using spring-boot 1.2.2. I have a hornet queue setup in application.properties:
spring.hornetq.mode=embedded
spring.hornetq.embedded.enabled=true
spring.hornetq.embedded.queues=myQueue
I have imported the integration-context.xml file.
#ImportResource("integration-context.xml")
And have defined the following activator:
<int:service-activator
input-channel="myQueue"
ref="myEndpointImpl"
method="send" >
</int:service-activator>
But when I put a message on myQueue the send method is not fired.
What am I doing wrong?
HornetQ is JMS Broker and having that configuration you just provide an embedded mode with one myQueue definition, which is created by Boot on application start up. See more info in the Spring Boot Manual.
Spring Integration allows to work with JMS through the appropriate adapters.
So, if you are going to listen to that HornetQ myQueue using Spring Integration and do some further integration flow you really should configure <int-jms:message-driven-channel-adapter> for that queue and go ahead with your <service-activator> etc. afterwards.
Feel free to ask more questions.
Related
I am looking for controlling ActiveMQ connections after starting of application in cluster environment if I want to disconnect some slave machine through code.
Any help around this will be really appreciable.
I don't believe Spring has any direct integration with ActiveMQ. Spring offers JMS integration which, of course, uses the generic JMS API which every JMS provider implements.
To manage ActiveMQ from a remote application will you need to use something like JMX.
I am new to Spring-Integration.
My use case is:
Listen to a RabbitMQ queue/topic, get the message, process it, send it to other message broker (mostly it will be another RabbitMQ instance).
Expected load: 5000 messages/sec
In application.properties we can set configurations for one host.
How to use Spring Integration between two message brokers?
All the examples that i see are for one message broker. Any pointers to get started with two message brokers and Spring Integration.
Regards,
Mahesh
Since you mention an application.properties it sounds like you use Spring Boot with its auto-configuration feature. It is very important detail in your question because Spring Boot has opinion about auto-configuration and you really can have only one broker connection configuration auto-configured. If you would like to have an another similar in the same application, then you should forget that auto-configuration feature. You still can use the mentioned application.properties, but you have to manage them manually.
Since you talk about a RabbitMQ connection, so you need to exclude RabbitAutoConfiguration and manage all the required beans manually:
#SpringBootApplication(exclude = RabbitAutoConfiguration.class)
You still can use the #EnableConfigurationProperties(RabbitProperties.class) on some your #Configuration class to be able to inject that RabbitProperties and populate respective CachingConnectionFactory. For the second broker you can introduce your own #ConfigurationProperties or just configure everything manually reading properties via #Value. See more info about manual connection factory configuration in Spring AMQP reference manual: https://docs.spring.io/spring-amqp/docs/2.2.1.RELEASE/reference/html/#connections
I'm trying to send messages using the JmsTemplate of Spring boot.
I configure everything using the autoconfiguration through properties.
These are the properties I set :
spring.activemq.broker-url
spring.activemq.user
spring.activemq.password
I have been able to get this working as desired when I configure the broker-url to tcp://localhost:61616, but whenever I change it to amqp://localhost:5672, I get the error :
Failed to connect to [amqp://localhost:5672] after: 10 attempt(s) continuing to retry.
For a project I'm working on, I should be using AMQP.
Any ideas?
Thanks in advance!
Boot's support for activemq is JMS only.
Spring does not have support for AMQP 1.0 at all; only 0.9.1 with RabbitMQ.
The Spring Boot documentation has this very brief illustration of an embedded JMS server: "Two beans that you don’t see defined are JmsTemplate and ConnectionFactory. These are created automatically by Spring Boot. In this case, the ActiveMQ broker runs embedded." Huh? The Reference Documentation doesn't say a thing about it. I need to create two VMs, each running from its own jar file, and I need one of them to launch an embedded JMS server, but I have no idea how to do this. Can somebody point me in the right direction. (If you provide a link, I would prefer some clear documentation over an example, but I'll be happy with a good example.)
You are looking at the wrong reference documentation. Yours is from Spring Integration.
The one of Spring Boot can be found here:
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-activemq
And there you will find the answer:
When ActiveMQ is available on the classpath, Spring Boot can also
configure a ConnectionFactory. If the broker is present, an embedded
broker is automatically started and configured (provided no broker URL
is specified through configuration).
I have recently started using Wildfly 8 and noticed that Wildfly8 has a built-in JMS utility called Hornetq. My question is, how can I configure hornetq to send and receive message on a JMS queue using Wildfly8 server?
There are a number of good tutorials on the net about how to use HornetQ (JMS) from within Widlfly, I like this one for JMS 2.0:
http://www.mastertheboss.com/jboss-server/jboss-jms/jms-20-tutorial-on-wildfly-as
Here is the hello world example from Wildfly themselves, illustrating how to implement an MDB and the respective listeners and topics:
https://github.com/wildfly/quickstart/tree/8.x/helloworld-mdb
That page describes everything in excellent detail and demonstrates the use of JMS 2.0 and EJB 3.2 Message-Driven Bean in WildFly 8. The project is runnable with maven and creates two JMS resources:
A queue named HELLOWORLDMDBQueue bound in JNDI as java:/queue/HELLOWORLDMDBQueue
A topic named HELLOWORLDMDBTopic bound in JNDI as java:/topic/HELLOWORLDMDBTopic
If you are having trouble with configuration of queues etc. in the standalone, the docs here are actually quite helpful as well:
https://docs.jboss.org/author/display/WFLY8/Messaging+configuration