ultraesb / resources / samples / conf / ultra-sample-705.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:u="http://www.adroitlogic.org/ultraesb"
       xmlns:s="http://www.springframework.org/schema/security"
       xmlns:amq="http://activemq.apache.org/schema/core"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.adroitlogic.org/ultraesb http://schemas.ultraesb.org/ultraesb-1.6.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <bean id="ultra-config" class="org.adroitlogic.ultraesb.core.ConfigurationImpl"/>

    <bean id="fileCache" class="org.adroitlogic.ultraesb.core.PooledMessageFileCache">
        <constructor-arg type="int" value="10"/>
    </bean>

    <bean id="http-8280" class="org.adroitlogic.ultraesb.transport.http.HttpNIOListener">
        <constructor-arg ref="fileCache"/>
        <property name="port" value="8280"/>
    </bean>

    <bean id="http-sender" class="org.adroitlogic.ultraesb.transport.http.HttpNIOSender">
        <constructor-arg ref="fileCache"/>
    </bean>

    <!-- Create an embedded ActiveMQ Broker for a quick demonstration - NOT recommended for production use -->
    <amq:broker useJmx="false" persistent="false">
        <amq:transportConnectors>
            <amq:transportConnector uri="tcp://localhost:0"/>
        </amq:transportConnectors>
    </amq:broker>

    <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
    <amq:connectionFactory id="queueConnectionFactory" brokerURL="vm://localhost"/>

    <!--Define JMS transport listener-->
    <bean id="jms-lsnr" class="org.adroitlogic.ultraesb.transport.jms.JMSTransportListener">
        <property name="connectionFactory" ref="queueConnectionFactory"/>
    </bean>

    <!--Define JMS transport sender-->
    <bean id="jms-sender" class="org.adroitlogic.ultraesb.transport.jms.JMSTransportSender">
        <property name="template">
            <bean id="jmsProducerTemplate" class="org.springframework.jms.core.JmsTemplate">
                <property name="connectionFactory" ref="queueConnectionFactory"/>
            </bean>
        </property>
    </bean>

    <!-- Caching/State replication configuration of the UltraESB server -->
    <bean id="cache-manager" class="org.adroitlogic.ultraesb.cache.ehcache.EhCacheManager">
        <property name="ehCacheConfig" value="conf/ehcache.xml"/>
    </bean>

    <u:proxy id="rest-proxy">
        <u:transport id="http-8280"/>
        <u:transport id="jms-lsnr">
            <u:property name="ultra.jms.reply_destination" value="Q.jmsResponse"/>
            <u:property name="cacheLevelName" value="CACHE_NONE"/>
        </u:transport>
        <u:target>
            <u:inSequence>
                <u:java import="org.adroitlogic.ultraesb.api.transport.jms.*;"><![CDATA[
                    mediation.sendToEndpoint(msg, "jmsRequestEndpoint");
                    // the actual message id assigned to the JMS message is required to correlate the response
                    final String jmsMessageId = msg.getFirstTransportHeader(JMSConstants.MESSAGE_ID);
                    mediation.getCachingSupport().getLocalCache().put(jmsMessageId, msg.createDefaultResponseMessage());
                ]]></u:java>
            </u:inSequence>
            <u:outSequence>
                <u:java import="org.adroitlogic.ultraesb.api.transport.jms.*; org.adroitlogic.ultraesb.api.cache.*;"><![CDATA[
                    final String responseCorrelationId = msg.getFirstTransportHeader(JMSConstants.CORRELATION_ID);
                    CacheEntry e = mediation.getCachingSupport().getLocalCache().getEntry(responseCorrelationId);
                    if (e != null) {
                        Message m = (Message) e.getValue();
                        m.setCurrentPayload(msg.getCurrentPayload());
                        mediation.sendResponse(m, 200);
                    } else {
                        logger.warn("Unable to send back response from JMS cache entry missing");
                    }
                ]]></u:java>
            </u:outSequence>
        </u:target>
    </u:proxy>

    <u:endpoint id="jmsRequestEndpoint">
        <u:address>jms:/Q.jmsRequest</u:address>
    </u:endpoint>

    <!--A mock JMS service that accepts the request on the Queue "Q.jmsRequest" and writes its "correlated"
    response to a Queue "Q.jmsResponse"
    The cacheLevelName attribute (Spring framework attribute) specified as a property to let the embedded
    ActiveMQ broker distinguish the mock service and rest-proxy as different connections without anything
    shared between-->
    <u:proxy id="jms-echo">
        <u:transport id="jms-lsnr">
            <u:property name="ultra.jms.destination" value="Q.jmsRequest"/>
            <u:property name="cacheLevelName" value="CACHE_NONE"/>
        </u:transport>
        <u:target>
            <u:inSequence>
                <u:java import="org.adroitlogic.ultraesb.api.transport.jms.*;"><![CDATA[
                    String msgid = msg.getFirstTransportHeader(JMSConstants.MESSAGE_ID);
                    mediation.setPayloadFromString(msg, "We have processed your REST request and here is the response");
                    msg.addTransportHeader(JMSConstants.CORRELATION_ID, msgid);
                ]]></u:java>
            </u:inSequence>
            <u:inDestination>
                <u:address>jms:/Q.jmsResponse</u:address>
            </u:inDestination>
        </u:target>
    </u:proxy>

</beans>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.