Package org.springframework.messaging

Examples of org.springframework.messaging.MessageChannel


     * Store reply message channel.
     * @param receivedMessage
     * @param context
     */
    public void saveReplyMessageChannel(Message receivedMessage, TestContext context) {
        MessageChannel replyChannel = null;
        if (receivedMessage.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL) instanceof MessageChannel) {
            replyChannel = (MessageChannel)receivedMessage.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL);
        } else if (StringUtils.hasText((String) receivedMessage.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL))){
            replyChannel = resolveChannelName(receivedMessage.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL).toString());
        }
View Full Code Here


  }

  @Override
  public void initialize() {
    List<AbstractEndpoint> endpoints = new ArrayList<AbstractEndpoint>();
    MessageChannel previousOutputChannel = null;
    for (int i = 0; i < this.modules.size(); i++) {
      Module module = this.modules.get(i);
      module.initialize();
      MessageChannel inputChannel = module.getComponent("input", MessageChannel.class);
      MessageChannel outputChannel = module.getComponent("output", MessageChannel.class);
      if (i == 0 && inputChannel != null) {
        // this will act as THE input for the composite module
        // if the first module has no input, the composite is a source
        this.context.getBeanFactory().registerSingleton("input", inputChannel);
      }
View Full Code Here

  public static void main(final String args[]) {
    final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONFIG, OutboundRunner.class);
    ctx.start();

    final MessageChannel channel = ctx.getBean("inputToKafka", MessageChannel.class);
    LOG.info(channel.getClass());

    //sending 100,000 messages to Kafka server for topic test1
    for (int i = 0; i < 500; i++) {
      final User user = new User();
      user.setFirstName("fname" + i);
      user.setLastName("lname" + i);
      channel.send(
          MessageBuilder.withPayload(user)
              .setHeader("messageKey", String.valueOf(i))
              .setHeader("topic", "test1").build());

      LOG.info("message sent " + i);
    }

    //sending 5,000 messages to kafka server for topic test2
    for (int i = 0; i < 50; i++) {
      channel.send(
        MessageBuilder.withPayload("hello Fom ob adapter test2 -  " + i)
          .setHeader("messageKey", String.valueOf(i))
          .setHeader("topic", "test2").build());

      LOG.info("message sent " + i);
    }

    //Send some messages to multiple topics matching regex.
    for (int i = 0; i < 10; i++) {
      channel.send(
        MessageBuilder.withPayload("hello Fom ob adapter regextopic1 -  " + i)
          .setHeader("messageKey", String.valueOf(i))
          .setHeader("topic", "regextopic1").build());

      LOG.info("message sent " + i);
    }
    for (int i = 0; i < 10; i++) {
      channel.send(
        MessageBuilder.withPayload("hello Fom ob adapter regextopic2 -  " + i)
          .setHeader("messageKey", String.valueOf(i))
          .setHeader("topic", "regextopic2").build());

      LOG.info("message sent " + i);
View Full Code Here

    FactoryBean serviceActivatorFactoryBean = applicationContext.getBean(ServiceActivatorFactoryBean.class);
    assertNotNull("ServiceActivatorFactoryBean must not be null", serviceActivatorFactoryBean);
    assertNotNull("Output channel must not be null", TestUtils.getPropertyValue(serviceActivatorFactoryBean, "outputChannel"));

    MessageChannel inputChannel = applicationContext.getBean("requests", MessageChannel.class);
    assertNotNull("Input channel must not be null", inputChannel);

    String targetMethodName = (String) TestUtils.getPropertyValue(serviceActivatorFactoryBean, "targetMethodName");
    assertNotNull("Target method name must not be null", targetMethodName);
    assertTrue("Target method name must be handleChunk, got: " + targetMethodName, "handleChunk".equals(targetMethodName));
View Full Code Here

   * @param channelName The name of the channel to be created, and registered as bean.
   * @param properties The properties.
   * @return The channel.
   */
  protected synchronized MessageChannel doBindDynamicProducer(String name, String channelName, Properties properties) {
    MessageChannel channel = this.directChannelProvider.lookupSharedChannel(channelName);
    if (channel == null) {
      try {
        channel = this.directChannelProvider.createAndRegisterChannel(channelName);
        bindProducer(name, channel, properties);
      }
View Full Code Here

   * @param properties The properties.
   * @return The channel.
   */
  protected synchronized MessageChannel doBindDynamicPubSubProducer(String name, String channelName,
      Properties properties) {
    MessageChannel channel = this.directChannelProvider.lookupSharedChannel(channelName);
    if (channel == null) {
      try {
        channel = this.directChannelProvider.createAndRegisterChannel(channelName);
        bindPubSubProducer(name, channel, properties);
      }
View Full Code Here

   *
   * @param module the module whose consumer and producers to bind to the {@link MessageBus}.
   */
  protected final void bindConsumerAndProducers(Module module) {
    Properties[] properties = extractConsumerProducerProperties(module);
    MessageChannel inputChannel = module.getComponent(MODULE_INPUT_CHANNEL, MessageChannel.class);
    if (inputChannel != null) {
      bindMessageConsumer(inputChannel, getInputChannelName(module), properties[0]);
    }
    MessageChannel outputChannel = module.getComponent(MODULE_OUTPUT_CHANNEL, MessageChannel.class);
    if (outputChannel != null) {
      bindMessageProducer(outputChannel, getOutputChannelName(module), properties[1]);
      String tapChannelName = buildTapChannelName(module);
      tappableChannels.put(tapChannelName, outputChannel);
      if (isTapActive(tapChannelName)) {
View Full Code Here

   * @param outputChannel the channel to tap
   */
  private void createAndBindTapChannel(String tapChannelName, MessageChannel outputChannel) {
    logger.info("creating and binding tap channel for {}", tapChannelName);
    if (outputChannel instanceof ChannelInterceptorAware) {
      MessageChannel tapChannel = tapOutputChannel(tapChannelName, (ChannelInterceptorAware) outputChannel);
      messageBus.bindPubSubProducer(tapChannelName, tapChannel, null); // TODO tap producer props
    }
    else {
      if (logger.isDebugEnabled()) {
        logger.debug("output channel is not interceptor aware. Tap will not be created.");
View Full Code Here

   * (stop sending new messages to the module so it can be stopped).
   *
   * @param module the module for which the consumer is to be unbound from the {@link MessageBus}.
   */
  protected void unbindConsumer(Module module) {
    MessageChannel inputChannel = module.getComponent(MODULE_INPUT_CHANNEL, MessageChannel.class);
    if (inputChannel != null) {
      messageBus.unbindConsumer(getInputChannelName(module), inputChannel);
      if (logger.isDebugEnabled()) {
        logger.debug("Unbound consumer for " + module.toString());
      }
View Full Code Here

   * (after it has been stopped).
   *
   * @param module the module for which producers are to be unbound from the {@link MessageBus}.
   */
  protected void unbindProducers(Module module) {
    MessageChannel outputChannel = module.getComponent(MODULE_OUTPUT_CHANNEL, MessageChannel.class);
    if (outputChannel != null) {
      messageBus.unbindProducer(getOutputChannelName(module), outputChannel);
      unbindTapChannel(buildTapChannelName(module));
      if (logger.isDebugEnabled()) {
        logger.debug("Unbound producer(s) for " + module.toString());
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.