Package org.springframework.messaging

Examples of org.springframework.messaging.MessageChannel


    }
  }

  private void unbindTapChannel(String tapChannelName) {
    // Should this be unbindProducer() as there won't be multiple producers on the tap channel.
    MessageChannel tappedChannel = tappableChannels.remove(tapChannelName);
    if (tappedChannel instanceof ChannelInterceptorAware) {
      ChannelInterceptorAware interceptorAware = ((ChannelInterceptorAware) tappedChannel);
      List<ChannelInterceptor> interceptors = new ArrayList<ChannelInterceptor>();
      for (ChannelInterceptor interceptor : interceptorAware.getChannelInterceptors()) {
        if (interceptor instanceof WireTap) {
View Full Code Here


   * @param client curator client
   * @param data module data
   */
  private void onTapAdded(CuratorFramework client, ChildData data) {
    String tapChannelName = buildTapChannelNameFromPath(data.getPath());
    MessageChannel outputChannel = tappableChannels.get(tapChannelName);
    if (outputChannel != null) {
      createAndBindTapChannel(tapChannelName, outputChannel);
    }
  }
View Full Code Here

  protected Job makeInstance(JobDefinition definition) {
    return new Job(definition);
  }

  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);
    if (job == null) {
      throwNoSuchDefinitionException(name);
    }
    if (instanceRepository.findOne(name) == null) {
      throwNotDeployedException(name);
    }
    // todo: is this Assert necessary? if not we can remove the parser dependency and parse method
    Assert.isTrue(parse(name, job.getDefinition()).size() == 1, "Expecting only a single module");
    channel.send(MessageBuilder.withPayload(jobParameters != null ? jobParameters : "").build());
  }
View Full Code Here

  private void processPartitionedJob(Module module) {
    if (logger.isDebugEnabled()) {
      logger.debug("binding job partitioning channels for " + module);
    }
    Properties[] properties = extractConsumerProducerProperties(module);
    MessageChannel partitionsOut = module.getComponent(JOB_PARTIONER_REQUEST_CHANNEL, MessageChannel.class);
    Assert.notNull(partitionsOut, "Partitioned jobs must have a " + JOB_PARTIONER_REQUEST_CHANNEL);
    MessageChannel partitionsIn = module.getComponent(JOB_PARTIONER_REPLY_CHANNEL, MessageChannel.class);
    Assert.notNull(partitionsIn, "Partitioned jobs must have a " + JOB_PARTIONER_REPLY_CHANNEL);
    ModuleDescriptor descriptor = module.getDescriptor();
    String name = descriptor.getGroup() + "." + descriptor.getIndex();
    messageBus.bindRequestor(name, partitionsOut, partitionsIn, properties[0]);

    MessageChannel stepExecutionsIn = module.getComponent(JOB_STEP_EXECUTION_REQUEST_CHANNEL, MessageChannel.class);
    Assert.notNull(stepExecutionsIn, "Partitioned jobs must have a " + JOB_STEP_EXECUTION_REQUEST_CHANNEL);
    MessageChannel stepExecutionResultsOut = module.getComponent(JOB_STEP_EXECUTION_REPLY_CHANNEL,
        MessageChannel.class);
    Assert.notNull(stepExecutionResultsOut, "Partitioned jobs must have a " + JOB_STEP_EXECUTION_REPLY_CHANNEL);
    messageBus.bindReplier(name, stepExecutionsIn, stepExecutionResultsOut, properties[1]);
  }
View Full Code Here

  private void unbindPartitionedJob(Module module) {
    if (logger.isDebugEnabled()) {
      logger.debug("unbinding job partitioning channels for " + module);
    }
    MessageChannel partitionsOut = module.getComponent(JOB_PARTIONER_REQUEST_CHANNEL, MessageChannel.class);
    ModuleDescriptor descriptor = module.getDescriptor();
    String name = descriptor.getGroup() + "." + descriptor.getIndex();
    if (partitionsOut != null) {
      messageBus.unbindProducer(name, partitionsOut);
    }
    MessageChannel partitionsIn = module.getComponent(JOB_PARTIONER_REPLY_CHANNEL, MessageChannel.class);
    if (partitionsIn != null) {
      messageBus.unbindConsumer(name, partitionsIn);
    }
    MessageChannel stepExcutionsIn = module.getComponent(JOB_STEP_EXECUTION_REQUEST_CHANNEL, MessageChannel.class);
    if (stepExcutionsIn != null) {
      messageBus.unbindConsumer(name, stepExcutionsIn);
    }
    MessageChannel stepExecutionResultsOut = module.getComponent(JOB_STEP_EXECUTION_REPLY_CHANNEL,
        MessageChannel.class);
    if (stepExecutionResultsOut != null) {
      messageBus.unbindProducer(name, stepExecutionResultsOut);
    }
  }
View Full Code Here

  @Override
  public void postProcessModule(Module module) {
    boolean disableListeners = true;
    Map<String, String> eventChannels = getEventListenerChannels(module);
    for (String publisherChannelName : eventChannels.keySet()) {
      MessageChannel eventChannel = module.getComponent(publisherChannelName, SubscribableChannel.class);
      if (eventChannel != null) {
        messageBus.bindPubSubProducer(eventChannels.get(publisherChannelName), eventChannel, null);
        disableListeners = false;
      }
    }
View Full Code Here

    return String.format("%s%s", JOB_TAP_CHANNEL_PREFIX, jobName);
  }

  private void bindAggregatedEventsChannel(Module module) {
    String jobName = module.getDescriptor().getGroup();
    MessageChannel aggEventsChannel = module.getComponent(XD_AGGREGATED_EVENTS_CHANNEL, SubscribableChannel.class);
    Assert.notNull(aggEventsChannel,
        "The pub/sub aggregatedEvents channel should be available in the module context.");
    messageBus.bindPubSubProducer(getEventListenerChannelName(jobName), aggEventsChannel, null);
  }
View Full Code Here

    this.producerProperties = producerProperties;
  }

  @Override
  public MessageChannel resolveDestination(String name) {
    MessageChannel channel = null;
    try {
      return super.resolveDestination(name);
    }
    catch (DestinationResolutionException e) {
    }
View Full Code Here

  private void doRegisterConsumer(String name, MessageChannel moduleInputChannel,
      SharedChannelProvider<?> channelProvider, Properties properties) {
    Assert.hasText(name, "a valid name is required to register an inbound channel");
    Assert.notNull(moduleInputChannel, "channel must not be null");
    MessageChannel registeredChannel = channelProvider.lookupOrCreateSharedChannel(name);
    bridge(name, registeredChannel, moduleInputChannel,
        "inbound." + ((NamedComponent) registeredChannel).getComponentName(),
        new LocalBusPropertiesAccessor(properties));
  }
View Full Code Here

  private void doRegisterProducer(String name, MessageChannel moduleOutputChannel,
      SharedChannelProvider<?> channelProvider, Properties properties) {
    Assert.hasText(name, "a valid name is required to register an outbound channel");
    Assert.notNull(moduleOutputChannel, "channel must not be null");
    MessageChannel registeredChannel = channelProvider.lookupOrCreateSharedChannel(name);
    bridge(name, moduleOutputChannel, registeredChannel,
        "outbound." + ((NamedComponent) registeredChannel).getComponentName(),
        new LocalBusPropertiesAccessor(properties));
  }
View Full Code Here

TOP

Related Classes of org.springframework.messaging.MessageChannel

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.