|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <beans xmlns="http://www.springframework.org/schema/beans" |
3 | | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
4 | | - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
5 | | - |
6 | | - <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> |
7 | | - <constructor-arg index="0" value="tcp://localhost:61616" /> |
8 | | - </bean> |
9 | | - |
10 | | - <!-- ConnectionFactory Definition --> |
11 | | - <bean id="connectionFactory" |
12 | | - class="org.springframework.jms.connection.CachingConnectionFactory"> |
13 | | - <constructor-arg ref="amqConnectionFactory" /> |
14 | | - </bean> |
15 | | - |
| 3 | + xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 4 | + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd |
| 5 | + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> |
| 6 | + |
| 7 | + <!-- JmsTemplate Definition --> |
| 8 | + <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> |
| 9 | + <property name="connectionFactory" ref="connectionFactory" /> |
| 10 | + <property name="defaultDestination" ref="destinationQueue" /> |
| 11 | + <property name="messageConverter" ref="myMessageConverter" /> |
| 12 | + </bean> |
| 13 | + <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> |
| 14 | + <constructor-arg index="0" value="tcp://localhost:61616" /> |
| 15 | + </bean> |
| 16 | + |
| 17 | + <!-- ConnectionFactory Definition --> |
| 18 | + <bean id="connectionFactory" |
| 19 | + class="org.springframework.jms.connection.SingleConnectionFactory"> |
| 20 | + <constructor-arg ref="amqConnectionFactory" /> |
| 21 | + |
| 22 | + </bean> |
| 23 | + |
| 24 | + |
16 | 25 | <bean id="destinationQueue" class="org.apache.activemq.command.ActiveMQQueue"> |
17 | | - <constructor-arg index="0" value="IN_QUEUE" /> |
18 | | - </bean> |
19 | | - |
20 | | - <!-- JmsTemplate Definition --> |
21 | | - <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> |
22 | | - <property name="connectionFactory" ref="connectionFactory" /> |
23 | | - <property name="defaultDestination" ref="destinationQueue" /> |
24 | | - </bean> |
| 26 | + <constructor-arg index="0" value="IN_QUEUE" /> |
| 27 | + </bean> |
| 28 | + |
| 29 | + |
25 | 30 | <bean id="SampleJmsMessageSender" class="com.baeldung.spring.jms.SampleJmsMessageSender"> |
26 | 31 | <property name="queue" ref="destinationQueue" /> |
27 | 32 | <property name="jmsTemplate" ref="jmsTemplate" /> |
28 | 33 | </bean> |
29 | 34 |
|
| 35 | + <bean id="myMessageConverter" class="com.baeldung.spring.jms.SampleMessageConverter" /> |
| 36 | + |
30 | 37 | <!-- this is the Message-Driven POJO (MDP) --> |
31 | | - <bean id="messageListener" class="com.baeldung.spring.jms.SampleListener" /> |
| 38 | + <bean id="messageListener" class="com.baeldung.spring.jms.SampleListener"> |
| 39 | + <property name="jmsTemplate" ref="jmsTemplate" /> |
| 40 | + <property name="queue" ref="destinationQueue" /> |
| 41 | + </bean> |
| 42 | + |
32 | 43 |
|
33 | 44 | <!-- and this is the message listener container --> |
34 | 45 | <bean id="jmsContainer" |
|
0 commit comments