Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- AMQP messaging configurations starts here -->
- <!-- Spring AMQP connection factory -->
- <rabbit:connection-factory id="connectionFactory"
- host="localhost"
- port="5672"
- username="guest"
- password="guest"
- channel-cache-size="25"/>
- <!-- Queues -->
- <rabbit:queue name="test.queue"/>
- <!-- Exchanges with their queue bindings -->
- <rabbit:topic-exchange name="test.exchange">
- <rabbit:bindings>
- <rabbit:binding queue="test.queue" pattern="test.*"/>
- </rabbit:bindings>
- </rabbit:topic-exchange>
- <!-- Spring AMQP template - Creates a bean which can send a message to the topicExchange-->
- <rabbit:template id="testTemplate"
- connection-factory="connectionFactory"
- exchange="test.exchange"/>
- <!-- Spring AMQP Admin -->
- <rabbit:admin connection-factory="connectionFactory"/>
- @Service
- public class AsyncQueueServiceImplementation implements AsyncQueueService
- {
- @Autowired
- private AmqpTemplate template;
- @Override
- @Async
- public void publish()
- {
- template.convertAndSend("test.debug", "test payload");
- }
- }
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(locations = { "classpath:application-context-unitTests.xml" })
- public class AsyncTraceServiceImplementationTest
- {
- @Autowired
- AsyncTraceService traceService;
- @Test
- public void testPublishAtDebugLevel()
- {
- traceService.publish();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement