mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3980 - generic support for all web socket tuning options
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1378035 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
53f07b0a75
commit
9b0316b9b4
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.transport;
|
||||
|
||||
import org.apache.activemq.util.IntrospectionSupport;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
|
@ -27,7 +28,9 @@ public class SocketConnectorFactory {
|
|||
private Map<String, Object> transportOptions;
|
||||
|
||||
public Connector createConnector() throws Exception {
|
||||
return new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
IntrospectionSupport.setProperties(connector, transportOptions, "");
|
||||
return connector;
|
||||
}
|
||||
|
||||
public Map<String, Object> getTransportOptions() {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.activemq.transport.TransportServer;
|
|||
import org.apache.activemq.util.IOExceptionSupport;
|
||||
import org.apache.activemq.util.IntrospectionSupport;
|
||||
import org.apache.activemq.util.URISupport;
|
||||
|
||||
/**
|
||||
*
|
||||
* Factory for WebSocket (ws) transport
|
||||
|
@ -40,7 +39,7 @@ public class WSTransportFactory extends TransportFactory {
|
|||
try {
|
||||
Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
|
||||
WSTransportServer result = new WSTransportServer(location);
|
||||
Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "transport.");
|
||||
Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "");
|
||||
result.setTransportOption(transportOptions);
|
||||
return result;
|
||||
} catch (URISyntaxException e) {
|
||||
|
|
|
@ -41,8 +41,6 @@ import java.util.Map;
|
|||
*/
|
||||
public class WSTransportServer extends WebTransportServerSupport {
|
||||
|
||||
int maxTextMessageSize = -1;
|
||||
|
||||
public WSTransportServer(URI location) {
|
||||
super(location);
|
||||
this.bindAddress = location;
|
||||
|
@ -64,9 +62,14 @@ public class WSTransportServer extends WebTransportServerSupport {
|
|||
new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY);
|
||||
|
||||
ServletHolder holder = new ServletHolder();
|
||||
if (maxTextMessageSize != -1) {
|
||||
holder.setInitParameter("maxTextMessageSize", String.valueOf(maxTextMessageSize));
|
||||
Map<String, Object> webSocketOptions = IntrospectionSupport.extractProperties(transportOptions, "websocket.");
|
||||
for(Map.Entry<String,Object> webSocketEntry : webSocketOptions.entrySet()) {
|
||||
Object value = webSocketEntry.getValue();
|
||||
if (value != null) {
|
||||
holder.setInitParameter(webSocketEntry.getKey(), value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
holder.setServlet(new StompServlet());
|
||||
contextHandler.addServlet(holder, "/");
|
||||
|
||||
|
@ -97,16 +100,9 @@ public class WSTransportServer extends WebTransportServerSupport {
|
|||
|
||||
@Override
|
||||
public void setTransportOption(Map<String, Object> transportOptions) {
|
||||
IntrospectionSupport.setProperties(this, transportOptions);
|
||||
socketConnectorFactory.setTransportOptions(transportOptions);
|
||||
Map<String, Object> socketOptions = IntrospectionSupport.extractProperties(transportOptions, "transport.");
|
||||
socketConnectorFactory.setTransportOptions(socketOptions);
|
||||
super.setTransportOption(transportOptions);
|
||||
}
|
||||
|
||||
public int getMaxTextMessageSize() {
|
||||
return maxTextMessageSize;
|
||||
}
|
||||
|
||||
public void setMaxTextMessageSize(int maxTextMessageSize) {
|
||||
this.maxTextMessageSize = maxTextMessageSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class WSSTransportFactory extends TransportFactory {
|
|||
try {
|
||||
Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
|
||||
WSSTransportServer result = new WSSTransportServer(location, SslContext.getCurrentSslContext());
|
||||
Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "transport.");
|
||||
Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "");
|
||||
result.setTransportOption(transportOptions);
|
||||
return result;
|
||||
} catch (URISyntaxException e) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class WSTransportTest {
|
|||
new URI("broker:()/localhost?persistent=false&useJmx=false"));
|
||||
|
||||
stompUri = broker.addConnector("stomp://localhost:0").getPublishableConnectString();
|
||||
wsUri = broker.addConnector("ws://127.0.0.1:61623").getPublishableConnectString();
|
||||
wsUri = broker.addConnector("ws://127.0.0.1:61623?websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001").getPublishableConnectString();
|
||||
broker.setDeleteAllMessagesOnStartup(deleteMessages);
|
||||
broker.start();
|
||||
broker.waitUntilStarted();
|
||||
|
|
Loading…
Reference in New Issue