Skip to content

MessageContextFile

rmuthupandian edited this page Feb 11, 2015 · 1 revision

This sample messagecontext Spring file shows how to provision message service with transports and contexts

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    
    
    <bean id="SystemPropertiesConfiguration"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
        lazy-init="false">
        <property name="targetClass" value="com.ebay.jetstream.config.ConfigUtils" />
        <property name="targetMethod" value="setSystemProperties" />
        <property name="arguments">
            <props>
                <prop key="com.ebay.jetstream.configdomain">
                    dev.geo-jetstream.com
                </prop>
                
            </props>
        </property>
    </bean>
   

    <!-- TRANSPORT SERVICE CONFIG -->
    <bean id="MessageServiceProperties"
        class="com.ebay.jetstream.messaging.config.MessageServiceProperties">
        <property name="nicUsage" ref="NICUsage" />
        <property name="transports">
            <list>
                <ref bean="zookeeper" />

                <bean
                    class="com.ebay.jetstream.messaging.transport.netty.config.NettyTransportConfig">
                    <property name="transportClass"
                        value="com.ebay.jetstream.messaging.transport.netty.NettyTransport" />
                    <property name="transportName" value="netty" />
                    <property name="protocol" value="tcp" />
                    <property name="contextList">
                        <list>
                            <bean
                                class="com.ebay.jetstream.messaging.transport.netty.config.NettyContextConfig">
                                <property name="contextname" value="Jetstream.demo" />
                                <property name="port" value="15590" />
                                <property name="scheduler" ref="consistenthashingaffinityscheduler"/>
                            </bean>
                        </list>
                    </property>
                    <!-- the netmask can be supplied through a system property named 'jetstream.runtime.netmask'.
                         This property selects the network interface over which the messages are going to flow.
                         You must set this property for the application to work properly. If the property is not
                         specified it will use local loopback
                      -->
                    <property name="netmask" value="#{systemProperties['jetstream.runtime.netmask'] ?: '127.0.0.1/8'}" />

                    <!-- the rest of the properties here are all defaulted and need not be set unless
                         you want to override the defaults -->

                    <property name="sendbuffersize" value="1048576" />
                    <property name="receivebuffersize" value="1048576" />
                    <property name="downstreamDispatchQueueSize" value="262144" />
                    <property name="connectionTimeoutInSecs" value="10" />
                    <property name="numAcceptorIoProcessors" value="1" />
                    <property name="numConnectorIoProcessors" value="1" />
                    <property name="connectionPoolSz" value="1" />
                    <property name="maxNettyBackLog" value="20000" />
                    <property name="idleTimeoutInSecs" value="8640000"/>
                    <property name="enableCompression" value="false" />
                    <property name="tcpKeepAlive" value="true"/>

                    <!-- if you want to enable batching you need to set the following properties. If
                         autoFlushSz is set to 0 batching is turned off. It should be set to the batch
                         size in bytes. Recommendation is to set it to integral multiples of 8192. The
                         autoFlushITimerInterval unit is millisecond.
                      -->
                    
                    <property name="autoFlushSz" value="8192" />
                    <property name="autoFlushTimeInterval" value="100"/>

                    
                </bean>
            </list>
        </property>
        <property name="upstreamDispatchQueueSize" value="300000" />
        <property name="upstreamDispatchThreadPoolSize" value="1" />
    </bean>


    <bean id="MessageService"
        class="com.ebay.jetstream.messaging.config.MessageServiceConfiguration"
        depends-on="SystemPropertiesConfiguration">
        <property name="messageServiceProperties" ref="MessageServiceProperties" />
    </bean>
    
    <bean id="consistenthashingaffinityscheduler"
        class="com.ebay.jetstream.messaging.transport.netty.eventscheduler.ConsistentHashingAffinityScheduler">
        <property name="hashFunctionClass"
            value="com.ebay.jetstream.messaging.transport.netty.schedulingalgorithm.consistenthashing.MurmurHashFunction" />
        <property name="numHashes" value="2000" />
        <property name="spreadFactor" value="987654321098" />
    </bean>
</beans>

Clone this wiki locally