All pastes #111843 Raw Edit

Someone

public text v1 · immutable
·published 2006-08-02 14:06 UTC
rendered paste body
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xbean.org/schemas/spring/1.0"
  xmlns:spring="http://xbean.org/schemas/spring/1.0"
  xmlns:sm="http://servicemix.org/config/1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xbean.org/schemas/spring/1.0 ../../conf/spring-beans.xsd
                      http://servicemix.org/config/1.0 ../../conf/servicemix.xsd"
  xmlns:my="http://servicemix.org/demo/">

  <!-- the JBI container -->
  <sm:container spring:id="jbi"
    useMBeanServer="true"
    createMBeanServer="true"    installationDirPath="../../install"
    monitorInstallationDirectory="true"
    dumpStats="true"
    statsInterval="10">

    <sm:activationSpecs>
      <!-- lets kick off a timer  every 5 seconds -->
        <!-- destinationService="my:httpGetData"> -->
      <sm:activationSpec componentName="timer"
        service="my:timer"
        destinationService="my:httpGetData">

        <sm:component>
          <bean xmlns="http://xbean.org/schemas/spring/1.0"
            class="org.servicemix.components.quartz.QuartzComponent">
            <property name="triggers">
              <map>
                <entry>
                  <key>                                                                                                  <bean class="org.quartz.SimpleTrigger">
                      <property name="repeatInterval" value="15000" />
                      <property name="repeatCount" value="-1" />
                    </bean>
                  </key>
                  <bean                                                                                                  class="org.quartz.JobDetail">
                    <property name="name" value="My Example Job" />                                                      <property name="group" value="ServiceMix" />
                  </bean>                                                                                            </entry>
              </map>
            </property>
          </bean>
        </sm:component>                                       

      </sm:activationSpec>

        <!-- destinationService="my:myreceiver"> -->
      <sm:activationSpec componentName="httpGetData"
        service="my:httpGetData"
        destinationService="my:trace">

        <sm:component>
          <bean xmlns="http://xbean.org/schemas/spring/1.0"
            class="org.servicemix.components.http.HttpInvoker">
            <property name="url" value="http://localhost:8080/" />
          </bean>
        </sm:component>

      </sm:activationSpec>

      <sm:activationSpec componentName="httpReceiver"
        service="my:httpBinding"
        endpoint="httpBinding"
        destinationService="my:sender">

        <sm:component>
          <bean xmlns="http://xbean.org/schemas/spring/1.0"
            class="org.servicemix.components.http.HttpConnector">
            <property name="host" value="localhost" />
            <property name="port" value="8080" />
          </bean>
        </sm:component>

      </sm:activationSpec>

      <sm:activationSpec componentName="sender"
        service="my:sender">
        <sm:component> <bean class="MySender" />  </sm:component>
      </sm:activationSpec>

      <sm:activationSpec componentName="receiver"
        service="my:receiver"
        destinationService="my:mailSender">
        <sm:component>
          <bean class="MyReceiver" />
        </sm:component>
      </sm:activationSpec>

      <sm:activationSpec componentName="mailSender"
        service="my:mailSender">
        <sm:component> <bean class="MyMailer" />  </sm:component>
      </sm:activationSpec>

      <!-- Route the event to a trace component that just outputs the event to the console -->
      <sm:activationSpec componentName="trace"
        service="my:trace">

        <sm:component>
          <bean xmlns="http://xbean.org/schemas/spring/1.0"
            class="org.servicemix.components.util.TraceComponent" />
        </sm:component>

      </sm:activationSpec>

    </sm:activationSpecs>
  </sm:container>

</beans>


This is the MySender.java

import java.io.BufferedReader;import java.io.FileReader;import javax.jbi.messaging.MessageExchange;import javax.jbi.messaging.MessagingException;import javax.jbi.messaging.NormalizedMessage;import javax.jbi.messaging.ExchangeStatus;import org.servicemix.MessageExchangeListener;import org.servicemix.components.util.PojoSupport;import org.servicemix.jbi.jaxp.StringSource;public class MySender extends PojoSupport implements MessageExchangeListener {        public void onMessageExchange(MessageExchange exchange) throws MessagingException {                System.out.println("IN onMessageExchange");                if ( exchange.getStatus() != ExchangeStatus.DONE ) {                        System.out.println("IN onMessageExchange and Status == " + exchange.getStatus() );                        NormalizedMessage message = exchange.createMessage();                        exchange.setMessage(message, "out");                        message.setContent(new StringSource(getQuote("quote.txt", "<quote>3.0</quote>")));                        done(exchange);                        //answer(exchange, message);                } else {                        System.out.println("IN onMessageExchange and Status == DONE");                }        }        private String getQuote(String fileName, String def) {                BufferedReader br = null;                String retval = "";                try {                           br =new BufferedReader                        (new FileReader(fileName));                        String line = "";                        while((line = br.readLine())!=null)                                retval += line;                } catch (Exception ex) {                  // ignore, use default                }                finally {                        if (br != null)                                try {                                           br.close();
                                } catch (Exception ex) {}                }                if (retval.length() == 0)                        return def;                else                        return retval;        }}


Poco:~/servicemix-2.0.2/examples/vsjmix jrizzo$ sh ../../bin/servicemix servicemix.xml
ServiceMix ESB: 2.0.2

Loading ServiceMix from file: servicemix.xml
09:49:19.087 EVENT  Starting Jetty/4.2.20RC0
09:49:19.106 EVENT  Started ServletHttpContext[/]
09:49:19.109 EVENT  Started SocketListener on 127.0.0.1:8080
09:49:19.109 EVENT  Started org.mortbay.jetty.Server@d1702e
IN onMessageExchange
IN onMessageExchange and Status == Active
09:49:19.417 WARN!! Exception for /
javax.jbi.messaging.MessagingException: illegal exchange status: done
        at org.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExchangeImpl.java:535)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:346)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:387)
        at org.servicemix.components.util.PojoSupport.done(PojoSupport.java:209)
        at MySender.onMessageExchange(Unknown Source)
        at org.servicemix.components.util.ComponentAdaptorMEListener.onMessageExchange(ComponentAdaptorMEListener.java:48)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:588)
        at org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171)
        at org.servicemix.jbi.nmr.flow.seda.SedaFlow.doSend(SedaFlow.java:140)
        at org.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:119)
        at org.servicemix.jbi.nmr.Broker.sendExchangePacket(Broker.java:289)
        at org.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:567)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:347)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:422)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:398)
        at org.servicemix.components.http.HttpInOutBinding.processInOut(HttpInOutBinding.java:61)
        at org.servicemix.components.http.HttpInOutBinding.process(HttpInOutBinding.java:46)
        at org.servicemix.components.http.BindingServlet.doPost(BindingServlet.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:615)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
        at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:657)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
       at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
        at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
        at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
        at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
        at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
        at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)

09:49:19,441 ERROR [PojoSupport] Error processing exchange
javax.jbi.messaging.MessagingException: Error executing http request
        at org.servicemix.components.http.HttpInvoker.transform(HttpInvoker.java:70)
        at org.servicemix.components.util.TransformComponentSupport.onMessageExchange(TransformComponentSupport.java:50)
        at org.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:588)
        at org.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171)
        at org.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:225)
        at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:613)
Caused by: org.servicemix.components.http.InvalidStatusResponseException: Invalid status response code: 500
        at org.servicemix.components.http.HttpInvoker.transform(HttpInvoker.java:62)
        ... 7 more