Announcement Announcement Module
Collapse
No announcement yet.
spring integration in osgi Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring integration in osgi

    I created a simple message.bus bundle that responsible for initiate the message bus and channel. These bean are exposed as an osgi services shown below. I have a publisher and subscriber bundle that wire up the channel using spring dm in s2ap. When I tried to use annotation in the subscriber bundle, it complaints not able to find the internal.MessageBus bean in its context. I am not sure how to expose the messagebus bean from the message bus bundle to the subscriber. Any ideas?

    [2008-09-22 10:23:23.269] platform-dm-7 <SPDE0020E> Application context creation failure for bundle 'com.packge.message.bus.subscriber.example'.
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'internal.PublisherAnnotationPostProcessor': Cannot resolve reference to bean 'internal.MessageBus' while setting bean property 'channelRegistry'; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'internal.MessageBus' is defined
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:104)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1245)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:881)
    at org.springframework.context.support.AbstractApplic ationContext.registerBeanPostProcessors(AbstractAp plicationContext.java:606)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.startRefresh(A bstractDelegatedExecutionApplicationContext.java:2 26)
    at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor.stageOne(DependencyWaiterApplicationContext Executor.java:221)
    at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor.refresh(DependencyWaiterApplicationContextE xecutor.java:172)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.refresh(Abstra ctDelegatedExecutionApplicationContext.java:136)
    at org.springframework.osgi.extender.internal.activat or.ContextLoaderListener$2.run(ContextLoaderListen er.java:749)
    at com.springsource.platform.kernel.dm.ContextPropaga tingTaskExecutor$2.run(ContextPropagatingTaskExecu tor.java:82)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'internal.MessageBus' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:387)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:968)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:246 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:269)
    ... 23 more



    message.bus context.xml

    I have routers that route messages from event channel to presenceChangedEvent channel.

    Code:
    <message-bus/>
    
    <annotation-driven/>
        
    <context:component-scan base-package="com.package.message.bus" />
    
    <channel id="events"/>	
    <channel id="characterEvents"/>	
    <publish-subscribe-channel id="presenceChangedEvent"/>
    
    <osgi:service ref="events"	   
           interface="org.springframework.integration.channel.MessageChannel">
       <service-properties>
          <entry key="channel" value="events"/>
       </service-properties>
    </osgi:service>
    	
    <osgi:service ref="presenceChangedEvent"
    	interface="org.springframework.integration.channel.MessageChannel">
       <service-properties>
          <entry key="channel" value="presenceChangedEvent"/>
       </service-properties>
    </osgi:service>
    Publisher bundle context.xml
    Code:
    <bean id="characterService" 
        class="com.package.message.bus.publisher.example.DummyCharacterService" init-method="init">
        	<property name="events" ref="events" />
    </bean>
    
    <osgi:reference id="events"		
    	interface="org.springframework.integration.channel.MessageChannel" filter="(channel=events)"/>
    Subscriber bundle context.xml
    Code:
    <annotation-driven/>
    
    <context:component-scan base-package="com.package.message.bus.subscriber" />
    
    <osgi:reference id="presenceChangedEvents"		
    	interface="org.springframework.integration.channel.MessageChannel" filter="(channel=presenceChangedEvents)" />

  • #2
    I think the publisher bundle and the subscriber bundle can't see the message bus. There is nothing special about Spring Integration as far as Spring DM is concerned, so beans (including message bus) are confined to the bundle context.

    Comment

    Working...
    X