Package org.springframework.integration.channel

Examples of org.springframework.integration.channel.DirectChannel


public class CamelSourceAdapterTest extends CamelSpringTestSupport {

    @Test
    public void testSendingOneWayMessage() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        DirectChannel channelA = getMandatoryBean(DirectChannel.class, "channelA");
        channelA.subscribe(new MessageHandler() {
            public void handleMessage(Message<?> message) {
                latch.countDown();
                assertEquals("We should get the message from channelA", message.getPayload(), "Willem");            
            }           
        });
View Full Code Here


        Map<String, Object> maps = new HashMap<String, Object>();
        maps.put(MessageHeaders.REPLY_CHANNEL, "responseChannel");

        Message<String> message = new GenericMessage<String>(MESSAGE_BODY, maps);

        DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("responseChannel");
        responseChannel.subscribe(new MessageHandler() {
            public void handleMessage(Message<?> message) {
                String result = (String) message.getPayload();
                assertEquals("Get the wrong result", MESSAGE_BODY + " is processed",  result);               
            }            
        });
View Full Code Here

  private void wireGatewaysToConsumers() {
    log.info("Building gateway service...");
    if (getNotificationConsumerService() != null) {
      for (NotificationConsumerStrategy s : getNotificationConsumerService().getConsumerStrategies()) {
        log.info("Wiring up gateway for consumer strategy " + s.getName() + "...");
        DirectChannel reply = new DirectChannel();
        reply.setBeanName("reply-"+s.getName());

        DirectChannel mc = new DirectChannel();
        mc.setBeanName("channel-"+s.getName());

        GatewayProxyFactoryBean gatewayProxy = new GatewayProxyFactoryBean();
        gatewayProxy.setDefaultRequestChannel(mc);
        gatewayProxy.setServiceInterface(NotificationGateway.class);
        gatewayProxy.setBeanFactory(getBeanFactory());
        gatewayProxy.setBeanName("gateway-"+s.getName());
        gatewayProxy.setComponentName("gateway-" + s.getName());
        gatewayProxy.setDefaultReplyChannel(reply);

        mc.subscribe(new ServiceActivatingHandler(s, "consume"));

        gatewayProxy.afterPropertiesSet();

        this.proxyMap.put(s.getName(), gatewayProxy);
      }
View Full Code Here

          spca.setSource(mfqms);
          spca.setOutputChannel(channelResolver.resolveChannelName(platformType + "StatusFileInputChannel"));
          spca.setAutoStartup(false);
          spca.afterPropertiesSet();

          DirectChannel outputChannel = (DirectChannel) channelResolver.resolveChannelName(platformType + "StatusChannel");
          outputChannel.setBeanName(platformType + "StatusChannel");
          outputChannel.setBeanFactory(context.getBeanFactory());

          if (props.containsKey("wiretap.enabled") && "true".equals(props.get("wiretap.enabled"))) {
            //set up wire tap
            DirectChannel wireTapChannel = (DirectChannel) channelResolver.resolveChannelName("wireTapChannel");
            wireTapChannel.setBeanName("wireTapChannel");
            wireTapChannel.setBeanFactory(context.getBeanFactory());

            LoggingHandler wireTapLogger = new LoggingHandler("TRACE");
            wireTapLogger.setBeanName("OutputWireTapper");
            wireTapLogger.setBeanFactory(context.getBeanFactory());
            wireTapLogger.setLoggerName("wiretap");
            wireTapLogger.setShouldLogFullMessage(true);
            wireTapLogger.afterPropertiesSet();
            wireTapChannel.subscribe(wireTapLogger);

            List<ChannelInterceptor> ints = new ArrayList<ChannelInterceptor>();
            WireTap wt = new WireTap(wireTapChannel);
            ints.add(wt);
            outputChannel.setInterceptors(ints);
          }

          DirectChannel signChannel = (DirectChannel)channelResolver.resolveChannelName(platformType+"MessageSignerChannel");
          signChannel.setBeanFactory(context.getBeanFactory());

          DirectChannel splitterChannel = (DirectChannel)channelResolver.resolveChannelName(platformType+"SplitterChannel");
          splitterChannel.setBeanFactory(context.getBeanFactory());

          if (props.containsKey(platformType + ".http.statusEndpointURIs")) {
            log.debug("Resolving " + platformType + ".http.statusEndpointURIs ...");
            String statusEndpointURIs = props.getProperty(platformType + ".http.statusEndpointURIs");
            for (String uri : statusEndpointURIs.split(",")) {
              //split into multiple messages
              MethodInvokingSplitter mis = new MethodInvokingSplitter(notificationUtils, "splitMessage");
              mis.setBeanName(platformType + "Splitter");
              mis.setBeanFactory(context.getBeanFactory());
              mis.setChannelResolver(channelResolver);
              mis.setOutputChannel(signChannel);
              splitterChannel.subscribe(mis);

              //sign messages and inject url into message headers via HeaderEnricher
              Map<String, SignedHeaderValueMessageProcessor<String>> urlHeaderToSign = new HashMap<String, SignedHeaderValueMessageProcessor<String>>();
              URI su = URI.create(uri);
              urlHeaderToSign.put("x-url", new SignedHeaderValueMessageProcessor<String>(su.getPath()));
View Full Code Here

    public WebSocketTcpConnectionInterceptor() {
      super();
      ResequencingMessageHandler handler = new ResequencingMessageHandler(new ResequencingMessageGroupProcessor());
      handler.setReleasePartialSequences(true);
      DirectChannel resequenced = new DirectChannel();
      resequenced.setBeanName("resequencedWSFrames");
      handler.setOutputChannel(resequenced);
      this.resequencer = new EventDrivenConsumer(this.resequenceChannel, handler);
      resequenced.subscribe(new MessageHandler() {

        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
          doOnMessage(message);
        }
View Full Code Here

  }

  @Test
  public void testWithMessageHistory() {
    Message<?> message = new GenericMessage<String>( "Hello" );
    final DirectChannel fooChannel = new DirectChannel();
    fooChannel.setBeanName( "fooChannel" );
    final DirectChannel barChannel = new DirectChannel();
    barChannel.setBeanName( "barChannel" );

    message = MessageHistory.write( message, fooChannel );
    message = MessageHistory.write( message, barChannel );
    store.addMessage( message );
    message = store.getMessage( message.getHeaders().getId() );
View Full Code Here

  @Test
  public void testWithMessageHistory() {
    MessageGroup messageGroup = store.getMessageGroup( 1 );
    Message<?> message = new GenericMessage<String>( "Hello" );
    DirectChannel fooChannel = new DirectChannel();
    fooChannel.setBeanName( "fooChannel" );
    DirectChannel barChannel = new DirectChannel();
    barChannel.setBeanName( "barChannel" );

    message = MessageHistory.write( message, fooChannel );
    message = MessageHistory.write( message, barChannel );
    store.addMessageToGroup( 1, message );
    message = store.getMessageGroup( 1 ).getMessages().iterator().next();
View Full Code Here

      listenerContainer.setAdviceChain(new Advice[] { retryInterceptor });
    }
    listenerContainer.afterPropertiesSet();
    AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
    adapter.setBeanFactory(this.getBeanFactory());
    DirectChannel bridgeToModuleChannel = new DirectChannel();
    bridgeToModuleChannel.setBeanFactory(this.getBeanFactory());
    bridgeToModuleChannel.setBeanName(name + ".bridge");
    adapter.setOutputChannel(bridgeToModuleChannel);
    adapter.setBeanName("inbound." + name);
    DefaultAmqpHeaderMapper mapper = new DefaultAmqpHeaderMapper();
    mapper.setRequestHeaderNames(properties.getRequestHeaderPattens(this.defaultRequestHeaderPatterns));
    mapper.setReplyHeaderNames(properties.getReplyHeaderPattens(this.defaultReplyHeaderPatterns));
    adapter.setHeaderMapper(mapper);
    adapter.afterPropertiesSet();
    Binding consumerBinding = Binding.forConsumer(name, adapter, moduleInputChannel, properties);
    addBinding(consumerBinding);
    ReceivingHandler convertingBridge = new ReceivingHandler();
    convertingBridge.setOutputChannel(moduleInputChannel);
    convertingBridge.setBeanName(name + ".convert.bridge");
    convertingBridge.afterPropertiesSet();
    bridgeToModuleChannel.subscribe(convertingBridge);
    consumerBinding.start();
  }
View Full Code Here

      }
    }
  }

  private MessageChannel tapOutputChannel(String tapChannelName, ChannelInterceptorAware outputChannel) {
    DirectChannel tapChannel = new DirectChannel();
    tapChannel.setBeanName(tapChannelName + ".tap.bridge");
    outputChannel.addInterceptor(new WireTap(tapChannel));
    return tapChannel;
  }
View Full Code Here

  }

  public void launch(String name, String jobParameters) {
    MessageChannel channel = jobChannels.get(name);
    if (channel == null) {
      jobChannels.putIfAbsent(name, new DirectChannel());
      channel = jobChannels.get(name);
      messageBus.bindProducer(JOB_CHANNEL_PREFIX + name, channel, null);
    }
    // Double check so that user gets an informative error message
    JobDefinition job = getDefinitionRepository().findOne(name);
View Full Code Here

TOP

Related Classes of org.springframework.integration.channel.DirectChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.