1

我正在尝试为 Mule ESB 2.2.1 设置一个配置文件,将传入请求路由到另一个盒子。这似乎很简单,但我收到连接被拒绝的异常,我不知道为什么。

这是我的 Mule 配置文件中的模型:

<model name="ProxySample">
    <service name="HttpProxyService">
        <inbound>
            <http:inbound-endpoint address="http://localhost:8787" synchronous="true"/>
        </inbound>
        <outbound>
            <pass-through-router>
                <outbound-endpoint address="http://server2.xyz.com:8080#[header:http.request]" synchronous="true"/>
            </pass-through-router>
        </outbound>
    </service>
</model>

我正在浏览器中浏览http://localhost:8787/my-site,认为它会路由到http://server2.xyz.com:8080/my-site,但我收到连接被拒绝错误。

下面是 Mule 服务器的控制台输出:

**********************************************************************
* Mule ESB and Integration Platform                                  *
* Version: 2.2.1 Build: 14422                                        *
* MuleSource, Inc.                                                   *
* For more information go to http://mule.mulesource.org              *
*                                                                    *
* Server started: 1/19/10 10:43 AM                                   *
* Server ID: 6802537d-0511-11df-bb89-710580f6c729                    *
* JDK: 1.6.0_18 (mixed mode, sharing)                                *
* OS encoding: UTF-8, Mule encoding: UTF-8                           *
* OS: Windows XP - Service Pack 3 (5.1, x86)                         *
* Host:                                      *
*                                                                    *
* Agents Running: None                                               *
**********************************************************************
INFO  2010-01-19 10:43:50,681 [connector.http.0.receiver.2] org.mule.transport.http.HttpClientMessageDispatcher: Connected: endpoint.outbound.http://localhost:8080#[header:http.request]
ERROR 2010-01-19 10:43:54,665 [connector.http.0.receiver.2] org.mule.DefaultExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod
Type                  : org.mule.api.transport.DispatchException
Code                  : MULE_ERROR-42999
Payload               : org.apache.commons.httpclient.methods.GetMethod@d67067
JavaDoc               : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html
********************************************************************************
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (null)
2. Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod (org.mule.api.transport.DispatchException)
  org.mule.transport.http.HttpClientMessageDispatcher:127 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    at java.net.Socket.<init>(Socket.java:246)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.mule.transport.http.HttpClientMessageDispatcher.execute(HttpClientMessageDispatcher.java:120)
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:258)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:163)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:2016)
    at org.mule.endpoint.DynamicURIOutboundEndpoint.send(DynamicURIOutboundEndpoint.java:178)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:152)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:159)
    at org.mule.routing.outbound.ChainingRouter.route(ChainingRouter.java:123)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:88)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:93)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:892)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:258)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:500)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:228)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:188)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:364)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:252)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:193)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:273)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:227)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)

********************************************************************************

INFO  2010-01-19 10:43:54,665 [connector.http.0.receiver.2] org.mule.transaction.TransactionTemplate: Exception Caught in Transaction template.  Handing off to exception handler: org.mule.service.DefaultServiceExceptionStrategy@1412e75
ERROR 2010-01-19 10:43:54,665 [connector.http.0.receiver.2] org.mule.service.DefaultServiceExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod
Type                  : org.mule.api.transport.DispatchException
Code                  : MULE_ERROR-42999
Payload               : org.apache.commons.httpclient.methods.GetMethod@d67067
JavaDoc               : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html
********************************************************************************
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (null)
2. Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod (org.mule.api.transport.DispatchException)
  org.mule.transport.http.HttpClientMessageDispatcher:127 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    at java.net.Socket.<init>(Socket.java:246)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.mule.transport.http.HttpClientMessageDispatcher.execute(HttpClientMessageDispatcher.java:120)
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:258)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:163)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:2016)
    at org.mule.endpoint.DynamicURIOutboundEndpoint.send(DynamicURIOutboundEndpoint.java:178)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:152)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:159)
    at org.mule.routing.outbound.ChainingRouter.route(ChainingRouter.java:123)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:88)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:93)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:892)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:258)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:500)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:228)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:188)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:364)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:252)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:193)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:273)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:227)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)

********************************************************************************

ERROR 2010-01-19 10:43:54,665 [connector.http.0.receiver.2] org.mule.service.DefaultServiceExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod
Type                  : org.mule.api.transport.DispatchException
Code                  : MULE_ERROR-42999
Payload               : org.apache.commons.httpclient.methods.GetMethod@d67067
JavaDoc               : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html
********************************************************************************
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (null)
2. Failed to route event via endpoint: org.mule.endpoint.DynamicURIOutboundEndpoint@6645e149. Message payload is of type: GetMethod (org.mule.api.transport.DispatchException)
  org.mule.transport.http.HttpClientMessageDispatcher:127 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    at java.net.Socket.<init>(Socket.java:246)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.mule.transport.http.HttpClientMessageDispatcher.execute(HttpClientMessageDispatcher.java:120)
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:258)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:163)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:2016)
    at org.mule.endpoint.DynamicURIOutboundEndpoint.send(DynamicURIOutboundEndpoint.java:178)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:152)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:159)
    at org.mule.routing.outbound.ChainingRouter.route(ChainingRouter.java:123)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:88)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:93)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:892)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:258)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:500)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:228)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:188)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:364)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:252)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:193)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:273)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:227)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)

********************************************************************************
4

2 回答 2

2

我的项目在 Eclipse 中没有正确清理。一旦我运行了正确的配置文件,上面的示例就会按预期工作。

于 2010-01-19T16:13:52.700 回答
1

这肯定可以工作,如果你不想让服务更具可读性,你也可以编写隐式组件:

<model name="ProxySample">
    <service name="HttpProxyService">
        <inbound>
            <http:inbound-endpoint address="http://localhost:8787" synchronous="true"/>
        </inbound>

        <bridge-component />

        <outbound>
            <pass-through-router>
                <outbound-endpoint address="http://server2.xyz.com:8080#[header:http.request]" synchronous="true"/>
            </pass-through-router>
        </outbound>
    </service>
</model>
于 2012-05-09T12:58:40.310 回答