Mule

A Single Jetty HTTP/Rest Connector does not support multiple endpoints

Details

  • Type: Patch submission Patch submission
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.3.3
  • Fix Version/s: 2.0.0
  • Labels:
    None
  • Environment:

    RedHat ES4, Mule 1.3.3, JVM 6

  • Includes test case?:
    no
  • Similar Issues:
    MULE-5811 Jetty SSL connector does not support the webapps element
    MULE-5134 When multiple connectors are specified dynamic endpoints errors.
    MULE-1188 Jetty Rest endpoints don't work
    MULE-1765 "Multiple connectors" error (when only a single connector present)
    MULE-3418 VM Connector cannot be configured to use a single thread on a singleton component
    MULE-4219 Quartz endpoint polling job does not process multiple files
    MULE-3508 MulticastingRouter needs a new feature to support the execution of multiple endpoints in order
    MULE-1665 Multiple connector configurations for same protocol confuses mule despite explicit references by name at endpoints
    MULE-2667 CLONE -Multiple connector configurations for same protocol confuses mule despite explicit references by name at endpoints
    MULE-520 And and Or filters on endpoints should support multiple filters not just 2

Description

The http/rest jetty transport opens its sockets on the receiver as opposed to the connector level. As such, a separate port binding is required for every endpoint, making it impossible to have 2 endpoints share the same port ie:

jetty:http://192.168.1.10:8082/endpoint1
jetty:http://192.168.1.10:8082/endpoint2

We need to expose a fairly large amount of endpoints and this wouldn't scale for us, so I patched the jetty/http transport as follows:

  • I moved the connection code from JettyHttpMessageReceiver.java into JavaConnector.java.
  • JettyConnector.java was modified to contain a Map of Server instances, keyed by host and port. When an endpoint is configured, it requests a Context from the Connector. If a Server is already in the Map for the endpoint's host and port, that Server instance is returned. If not, a new instance is created and put into the Map.
  • Modified JettyHttpMessageReceiver.java to name its Servlet after the endpoint name (as opposed to "JettyReceiverServlet" or "MuleRESTReceiverServlet")
  • The JettyHttpMessgeReceiver is pushed into the ServletContext keyed by the servlet name and appended with "Receiver"
  • The Jetty Server is stopped (if running) and started again to pick up the new handler (probably a better way to do this)
  • Modified JettyReceiverServlet to pull the receiver out of the context based on the Servlet name.

Here is the relevant thread from the user list:

http://www.nabble.com/multiple-http-jetty-endpoints-on-a-single-connector-tf3434293.html#a9574825

  1. JettyConnector.java.patch
    22/Mar/07 09:22 AM
    5 kB
    john demic
  2. JettyHttpMessageReceiver.java.patch
    22/Mar/07 09:22 AM
    8 kB
    john demic
  3. JettyReceiverServlet.java.patch
    22/Mar/07 09:22 AM
    0.7 kB
    john demic

Activity

Hide
Andrius Paulauskas added a comment - 04/May/07 05:16 AM

Successfully patched to 1.4.0 http provider module, passed all module tests. Thanks.

Show
Andrius Paulauskas added a comment - 04/May/07 05:16 AM Successfully patched to 1.4.0 http provider module, passed all module tests. Thanks.

People

Vote (2)
Watch (3)

Dates

  • Created:
    22/Mar/07 09:22 AM
    Updated:
    29/Nov/08 05:27 PM
    Resolved:
    29/Nov/08 05:27 PM