Introducing Spring Framework
Introducing Spring Framework Introducing Spring Framework
Chapter 11 ■ Integrating Your Spring Application with External Systems Listing 11-8. mydocuments-context.xml Listing 11-8 shows you the jmsTemplate bean that references the org.springframework.jms.core.JmsTemplate class. The JmsTemplate has a constructor where it’s being referenced to the activemqConnectionFactory bean and it has a property that will be the name of the queue, mydocumentsQueue. This will help the template to send messages to the correct destination queue. Listing 11-9 shows the modification of the previous test. 157
Chapter 11 ■ Integrating Your Spring Application with External Systems Listing 11-9. MyDocumentTest.java package com.apress.isf.spring.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.apress.isf.java.model.Document; import com.apress.isf.java.model.Type; import com.apress.isf.java.service.SearchEngine; import com.apress.isf.java.utils.XmlUtils; import com.apress.isf.spring.amqp.RabbitMQProducer; import com.apress.isf.spring.jms.JMSProducer; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:META-INF/spring/mydocuments-context.xml") @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MyDocumentsTest { private static final Logger log = LoggerFactory.getLogger(MyDocumentsTest.class); //Based on the META-INF/data/jms.txt - only one record private static final int MAX_ALL_DOCS = 5; private static final int MAX_WEB_DOCS = 2; @Autowired private SearchEngine engine; @Test public void testSpringJMS_1(){ log.debug("Testing Spring JMS Producer..."); jmsProducer.send(); } @Test public void testSpringJMS_2() throws InterruptedException { log.debug("Testing Spring JMS Listener/Insert..."); assertNotNull(engine); 158
- Page 105 and 106: Chapter 8 ■ Give Advice to Your S
- Page 107 and 108: Chapter 8 ■ Give Advice to Your S
- Page 109 and 110: Chapter 8 ■ Give Advice to Your S
- Page 111 and 112: Chapter 9 ■ Adding Persistence to
- Page 113 and 114: Chapter 9 ■ Adding Persistence to
- Page 115 and 116: Chapter 9 ■ Adding Persistence to
- Page 117 and 118: Chapter 9 ■ Adding Persistence to
- Page 119 and 120: Chapter 9 ■ Adding Persistence to
- Page 121 and 122: Chapter 9 ■ Adding Persistence to
- Page 123 and 124: Chapter 9 ■ Adding Persistence to
- Page 125 and 126: Chapter 9 ■ Adding Persistence to
- Page 127 and 128: Chapter 9 ■ Adding Persistence to
- Page 129 and 130: Chapter 9 ■ Adding Persistence to
- Page 131 and 132: Chapter 9 ■ Adding Persistence to
- Page 133 and 134: Chapter 10 ■ Showing Your Spring
- Page 135 and 136: Chapter 10 ■ Showing Your Spring
- Page 137 and 138: Chapter 10 ■ Showing Your Spring
- Page 139 and 140: Chapter 10 ■ Showing Your Spring
- Page 141 and 142: Chapter 10 ■ Showing Your Spring
- Page 143 and 144: Chapter 10 ■ Showing Your Spring
- Page 145 and 146: Chapter 11 ■ Integrating Your Spr
- Page 147 and 148: Chapter 11 ■ Integrating Your Spr
- Page 149 and 150: Chapter 11 ■ Integrating Your Spr
- Page 151 and 152: Chapter 11 ■ Integrating Your Spr
- Page 153 and 154: Chapter 11 ■ Integrating Your Spr
- Page 155: Chapter 11 ■ Integrating Your Spr
- Page 159 and 160: Chapter 11 ■ Integrating Your Spr
- Page 161 and 162: Chapter 11 ■ Integrating Your Spr
- Page 163 and 164: Chapter 11 ■ Integrating Your Spr
- Page 165 and 166: Chapter 11 ■ Integrating Your Spr
- Page 167 and 168: Chapter 12 Exposing a REST API Nowa
- Page 169 and 170: Chapter 12 ■ Exposing a REST API
- Page 171 and 172: Chapter 12 ■ Exposing a REST API
- Page 173 and 174: Chapter 12 ■ Exposing a REST API
- Page 175 and 176: Chapter 12 ■ Exposing a REST API
- Page 177 and 178: Chapter 12 ■ Exposing a REST API
- Page 179 and 180: HTTP-DELETE Chapter 12 ■ Exposing
- Page 181 and 182: Chapter 13 Adding E-mail and Schedu
- Page 183 and 184: Chapter 13 ■ Adding E-mail and Sc
- Page 185 and 186: Chapter 13 ■ Adding E-mail and Sc
- Page 187 and 188: Chapter 13 ■ Adding E-mail and Sc
- Page 189 and 190: Chapter 13 ■ Adding E-mail and Sc
- Page 191 and 192: Part III Spring Framework Advanced
- Page 193 and 194: Chapter 14 ■ Using Dynamic Langua
- Page 195 and 196: Chapter 14 ■ Using Dynamic Langua
- Page 197 and 198: Chapter 14 ■ Using Dynamic Langua
- Page 199 and 200: Chapter 14 ■ Using Dynamic Langua
- Page 201 and 202: Chapter 15 ■ Spring Data Within Y
- Page 203 and 204: Chapter 15 ■ Spring Data Within Y
- Page 205 and 206: Chapter 15 ■ Spring Data Within Y
Chapter 11 ■ Integrating Your <strong>Spring</strong> Application with External Systems<br />
Listing 11-8. mydocuments-context.xml<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Listing 11-8 shows you the jmsTemplate bean that references the org.springframework.jms.core.JmsTemplate<br />
class. The JmsTemplate has a constructor where it’s being referenced to the activemqConnectionFactory bean and it<br />
has a property that will be the name of the queue, mydocumentsQueue. This will help the template to send messages to<br />
the correct destination queue. Listing 11-9 shows the modification of the previous test.<br />
157