List of usage examples for org.springframework.integration.amqp.outbound AmqpOutboundEndpoint afterPropertiesSet
@Override public final void afterPropertiesSet()
From source file:org.springframework.integration.amqp.config.AmqpOutboundChannelAdapterParserTests.java
@Test public void testInt3430FailForNotLazyConnect() { RabbitTemplate amqpTemplate = spy(new RabbitTemplate()); ConnectionFactory connectionFactory = mock(ConnectionFactory.class); RuntimeException toBeThrown = new RuntimeException("Test Connection Exception"); doThrow(toBeThrown).when(connectionFactory).createConnection(); when(amqpTemplate.getConnectionFactory()).thenReturn(connectionFactory); AmqpOutboundEndpoint handler = new AmqpOutboundEndpoint(amqpTemplate); Log logger = spy(TestUtils.getPropertyValue(handler, "logger", Log.class)); new DirectFieldAccessor(handler).setPropertyValue("logger", logger); doAnswer(new DoesNothing()).when(logger).error("Failed to eagerly establish the connection.", toBeThrown); ApplicationContext context = mock(ApplicationContext.class); handler.setApplicationContext(context); handler.setBeanFactory(context);/* w w w. j a v a 2 s . c om*/ handler.afterPropertiesSet(); handler.start(); handler.stop(); verify(logger, never()).error(anyString(), any(RuntimeException.class)); handler.setLazyConnect(false); handler.start(); verify(logger).error("Failed to eagerly establish the connection.", toBeThrown); handler.stop(); }
From source file:org.springframework.integration.x.rabbit.RabbitMessageBus.java
private AmqpOutboundEndpoint buildOutboundEndpoint(final String name) { rabbitAdmin.declareQueue(new Queue(name)); AmqpOutboundEndpoint queue = new AmqpOutboundEndpoint(rabbitTemplate); queue.setRoutingKey(name); // uses default exchange queue.setHeaderMapper(mapper);//from ww w .jav a 2 s. c om queue.afterPropertiesSet(); return queue; }
From source file:org.springframework.integration.x.rabbit.RabbitMessageBus.java
@Override public void bindPubSubProducer(String name, MessageChannel moduleOutputChannel) { rabbitAdmin.declareExchange(new FanoutExchange("topic." + name)); AmqpOutboundEndpoint fanout = new AmqpOutboundEndpoint(rabbitTemplate); fanout.setExchangeName("topic." + name); fanout.setHeaderMapper(mapper);/* ww w. j av a 2 s .c o m*/ fanout.afterPropertiesSet(); doRegisterProducer(name, moduleOutputChannel, fanout); }
From source file:org.springframework.integration.x.rabbit.RabbitMessageBus.java
@Override public void bindReplier(String name, MessageChannel requests, MessageChannel replies) { if (logger.isInfoEnabled()) { logger.info("binding replier: " + name); }//from w ww . j av a2s . c o m Queue requestQueue = new Queue(name + ".requests"); this.rabbitAdmin.declareQueue(requestQueue); this.doRegisterConsumer(name, requests, requestQueue); AmqpOutboundEndpoint replyQueue = new AmqpOutboundEndpoint(rabbitTemplate); replyQueue.setBeanFactory(new DefaultListableBeanFactory()); replyQueue.setRoutingKeyExpression("headers['" + AmqpHeaders.REPLY_TO + "']"); replyQueue.setHeaderMapper(mapper); replyQueue.afterPropertiesSet(); doRegisterProducer(name, replies, replyQueue); }
From source file:org.springframework.xd.dirt.integration.rabbit.RabbitMessageBus.java
private void configureOutboundHandler(AmqpOutboundEndpoint handler, RabbitPropertiesAccessor properties) { DefaultAmqpHeaderMapper mapper = new DefaultAmqpHeaderMapper(); mapper.setRequestHeaderNames(properties.getRequestHeaderPattens(this.defaultRequestHeaderPatterns)); mapper.setReplyHeaderNames(properties.getReplyHeaderPattens(this.defaultReplyHeaderPatterns)); handler.setHeaderMapper(mapper);//from w ww . j av a 2s . c o m handler.setDefaultDeliveryMode(properties.getDeliveryMode(this.defaultDefaultDeliveryMode)); handler.setBeanFactory(this.getBeanFactory()); handler.afterPropertiesSet(); }