Results 1 to 5 of 5

Thread: MessageBusParser

  1. #1

    Default MessageBusParser

    Hi guys.
    I've just tried to make my first HelloWorld spring-integration app, and got the exception: No bean named 'internal.MessageBus' is defined.

    Here is my context:
    Code:
    
    <beans:beans xmlns="http://www.springframework.org/schema/integration"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
    			http://www.springframework.org/schema/context
    			http://www.springframework.org/schema/context/spring-context-2.5.xsd">		
    			
    	<message-bus/>
    			
    	<beans:bean id="helloService" class="com.integration.HelloService"/>
    
    	<endpoint input-channel="inputChannel"
    	          default-output-channel="outputChannel"
    	          handler-ref="helloService"
    	          handler-method="sayHello" />
    			
    </beans:beans>
    HelloService class:
    Code:
    package com.integration;
    
    public class HelloService {
    	
    	public String sayHello(String name) {
    		
    		return "Hello" + name;
    		
    	}
    
    }
    here is how I run the example:
    Code:
    ApplicationContext context = new ClassPathXmlApplicationContext("integrationContext.xml");
    		
    		ChannelRegistry channelRegistry = (ChannelRegistry) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
    		MessageChannel inputChannel = channelRegistry.lookupChannel("inputChannel");
    		MessageChannel outputChannel = channelRegistry.lookupChannel("outputChannel");
    		inputChannel.send(new StringMessage(new Integer(1),"World"));
    		System.out.println(outputChannel.receive().getPayload());
    Could you please point me on whats whrong here?

    Thanks.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    That context file you've provided is named "integrationContext.xml" and is located at the root of the classpath?

  3. #3

    Default

    Yes. The context file is visible by application.
    Here is the stack trace:
    Code:
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.integration.scheduling.Subscription#0': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.integration.channel.MessageChannel]: Could not convert constructor argument value of type [java.lang.String] to required type [org.springframework.integration.channel.MessageChannel]: Failed to convert value of type [java.lang.String] to required type [org.springframework.integration.channel.MessageChannel]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [org.springframework.integration.channel.MessageChannel]: no matching editors or conversion strategy found
    	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:501)
    	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:176)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:877)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:796)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:489)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:243)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:252)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:102)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1193)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:961)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:507)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:243)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:268)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:257)
    	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:887)
    	at org.springframework.integration.bus.MessageBus.registerEndpoints(MessageBus.java:155)
    	at org.springframework.integration.bus.MessageBus.setApplicationContext(MessageBus.java:103)
    	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:72)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:315)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1275)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:510)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:243)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:351)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:689)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:358)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
    	at com.integration.TestIntegration.main(TestIntegration.java:14)

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Sorry that I didn't notice this the first time, but you haven't defined the "inputChannel" and "outputChannel" beans. There are two options:

    1) define them explicitly in the xml (with the advantage of being able to configure properties such as 'capacity' and also provide interceptors if desired):
    Code:
    <channel id="inputChannel"/>
    <channel id="outputChannel"/>
    2) enable the 'auto-create-channels' option for the MessageBus:
    Code:
    <message-bus auto-create-channels="true"/>
    -Mark

  5. #5

    Default

    Huh. Thanks It works now.
    There is nothing about that in the example I found in internet.

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •