Announcement Announcement Module
Collapse
No announcement yet.
Distributed channels using Hazelcast Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Distributed channels using Hazelcast

    Hi all,

    If anyone is interested, I've set up simple test of using Hazelcast (os data distribution platform with implementations of distributed queues, maps,...) for distributed channels in SI. Btw, I'm newbie to SI so maybe this is totaly wrong from architecural or some other perspective.
    Message flow is simple: Producer running on JVM 1 creates simple text message and sends it to distributed channel, consumer (stdout-channel-adapter) running on JVM 2 polls this distributed channel for messages and simply prints out payload.

    1. HazelcatQueueFactoryBean:
    Code:
    public class HazelcastQueueFactoryBean implements FactoryBean {
    	
    	private String name;
    	
    
    	@Override
    	public Object getObject() throws Exception {
    		// TODO Auto-generated method stub
    		return Hazelcast.getQueue(name);
    	}
    
    	@Override
    	public Class<?> getObjectType() {
    		// TODO Auto-generated method stub
    		return BlockingQueue.class;
    	}
    
    	@Override
    	public boolean isSingleton() {
    		// TODO Auto-generated method stub
    		return true;
    	}
    
    	public String getName() {
    		return name;
    	}
    
    	public void setName(String name) {
    		this.name = name;
    	}
    
    }
    Producer config:
    Code:
    <beans:bean class="si.zav_triglav.rms.si.HazelcastQueueFactoryBean" id="hazelcastQueue">
    	<beans:property name="name" value="hazelcastQueue"></beans:property>
    	
    </beans:bean>
    
    <beans:bean class="org.springframework.integration.channel.QueueChannel" id="hazelcastChannel">
    	<beans:constructor-arg index="0" ref="hazelcastQueue"></beans:constructor-arg>
    	
    </beans:bean>
    Consumer config:
    Code:
    <poller id="defaultPoller" default="true" >
         <interval-trigger interval="1" time-unit="SECONDS"/>
     </poller>
    
    <beans:bean class="si.zav_triglav.rms.si.HazelcastQueueFactoryBean" id="hazelcastQueue">
    	<beans:property name="name" value="hazelcastQueue"></beans:property>
    	
    </beans:bean>
    
    <beans:bean class="org.springframework.integration.channel.QueueChannel" id="hazelcastChannel">
    	<beans:constructor-arg index="0" ref="hazelcastQueue"></beans:constructor-arg>
    	
    </beans:bean>
    	
    <stream:stdout-channel-adapter id="stdoutAdapterWithDefaultCharset" channel="hazelcastChannel"/>

    Producer:
    Code:
    ...
    MessageChannel  channel = (MessageChannel)getContext().getBean("hazelcastChannel");
    		
    MessageChannelTemplate template = new  MessageChannelTemplate();
    	
    		Message<String> message  = MessageBuilder.withPayload("kukukuk").build();
    		
    		template.send(message, channel);
    ...
    Consumer just loads spring config:
    Code:
    ClassPathXmlApplicationContext(
    			new String[] { "si/zav_triglav/rms/si/receiver.xml"});
    Simon

  • #2
    Yeah!

    We just need to make it simpler to provide a custom queue.
    Code:
    <channel>
      <queue ref="hazelCastQueue"/>
    <channel>

    Comment


    • #3
      Originally posted by iwein View Post
      Yeah!

      We just need to make it simpler to provide a custom queue.
      Code:
      <channel>
        <queue ref="hazelCastQueue"/>
      <channel>
      That would be my next suggestion

      simon

      Comment


      • #4
        By the way, you can leave out the factory bean if you do
        Code:
        <beans:bean class="...Hazelcast" factory-method="getQueue">
        <beans:contructor-arg value="queueName"/>
        </beans:bean>

        Comment


        • #5
          Vote for http://jira.springframework.org/browse/INT-634 if you need this fixed.

          Comment

          Working...
          X