[jboss-cvs] JBoss Messaging SVN: r5949 - in trunk: examples/messaging/src/org/jboss/messaging/example and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Feb 28 09:58:12 EST 2009
Author: ataylor
Date: 2009-02-28 09:58:12 -0500 (Sat, 28 Feb 2009)
New Revision: 5949
Removed:
trunk/src/main/org/jboss/messaging/servlet/
Modified:
trunk/build-messaging.xml
trunk/examples/messaging/src/org/jboss/messaging/example/HttpClient.java
trunk/src/WEB-INF/web.xml
trunk/src/config/jbm-configuration.xml
trunk/src/config/jbm-jms.xml
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/TransportConstants.java
Log:
servlet integration
Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/build-messaging.xml 2009-02-28 14:58:12 UTC (rev 5949)
@@ -202,11 +202,6 @@
<path refid="jboss.integration.classpath"/>
</path>
- <path id="servlet.compilation.classpath">
- <path location="${build.core.classes.dir}"/>
- <path refid="jboss.jboss.javaee.classpath"/>
- </path>
-
<path id="transports.compilation.classpath">
<path location="${build.core.classes.dir}"/>
<path refid="jboss.jboss.javaee.classpath"/>
@@ -780,24 +775,11 @@
<include name="WEB-INF/*"/>
</fileset>
</copy>
- <mkdir dir="${build.war.dir}/WEB-INF/classes"/>
- <javac destdir="${build.war.dir}/WEB-INF/classes"
- target="${javac.target}"
- source="${javac.source}"
- optimize="${javac.optimize}"
- debug="${javac.debug}"
- depend="${javac.depend}"
- verbose="${javac.verbose}"
- deprecation="${javac.deprecation}"
- includeAntRuntime="${javac.include.ant.runtime}"
- includeJavaRuntime="${javac.include.java.runtime}"
- failonerror="${javac.fail.onerror}">
- <src>
- <pathelement path="${src.main.dir}"/>
- </src>
- <include name="**/messaging/servlet/*.java"/>
- <classpath refid="servlet.compilation.classpath"/>
- </javac>
+ <copy todir="${build.sar.dir}">
+ <fileset dir="${src.schemas.dir}">
+ <include name="*"/>
+ </fileset>
+ </copy>
</target>
<target name="distro" depends="jar, jar-client, validate-configuration">
Modified: trunk/examples/messaging/src/org/jboss/messaging/example/HttpClient.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/HttpClient.java 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/HttpClient.java 2009-02-28 14:58:12 UTC (rev 5949)
@@ -21,8 +21,6 @@
*/
package org.jboss.messaging.example;
-import java.util.HashMap;
-
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
@@ -33,6 +31,8 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.utils.SimpleString;
+import java.util.HashMap;
+
/**
* Uses the core messaging API to send and receive a message to a queue via http. You will need to enable the server with
* the netty http acceptor for this to work.
@@ -46,6 +46,8 @@
{
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("jbm.remoting.netty.httpenabled", true);
+ //to use the servlet transport change the last line to
+ //map.put("jbm.remoting.netty.useservlet", true);
params.put("jbm.remoting.netty.port", 8080);
ClientSessionFactory sessionFactory =
new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory", params));
Modified: trunk/src/WEB-INF/web.xml
===================================================================
--- trunk/src/WEB-INF/web.xml 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/WEB-INF/web.xml 2009-02-28 14:58:12 UTC (rev 5949)
@@ -1,17 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <context-param>
+ <param-name>serverChannelName</param-name>
+ <param-value>org.jboss.jbm</param-value>
+ </context-param>
+ <context-param>
+ <param-name>streaming</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>reconnectTimeout</param-name>
+ <param-value>3000</param-value>
+ </context-param>
+
<listener>
- <listener-class>org.jboss.messaging.servlet.JBMSessionListener</listener-class>
+ <listener-class>org.jboss.netty.channel.socket.http.HttpTunnelingSessionListener</listener-class>
</listener>
+ <listener>
+ <listener-class>org.jboss.netty.channel.socket.http.HttpTunnelingContextListener</listener-class>
+ </listener>
+
<servlet>
- <servlet-name>JBMServlet</servlet-name>
- <servlet-class>org.jboss.messaging.servlet.JBMServlet</servlet-class>
+ <servlet-name>NettyServlet</servlet-name>
+ <servlet-class>org.jboss.netty.channel.socket.http.HttpTunnelingServlet</servlet-class>
</servlet>
<servlet-mapping>
- <servlet-name>JBMServlet</servlet-name>
+ <servlet-name>NettyServlet</servlet-name>
<url-pattern>/JBMServlet</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
Modified: trunk/src/config/jbm-configuration.xml
===================================================================
--- trunk/src/config/jbm-configuration.xml 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/config/jbm-configuration.xml 2009-02-28 14:58:12 UTC (rev 5949)
@@ -81,6 +81,13 @@
<param key="jbm.remoting.netty.httpclientidletime" value="500" type="Long"/>
<param key="jbm.remoting.netty.httpclientidlescanperiod" value="500" type="Long"/>
</connector>
+
+ <connector name="netty-servlet">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ <param key="jbm.remoting.netty.host" value="localhost" type="String"/>
+ <param key="jbm.remoting.netty.port" value="8080" type="Integer"/>
+ <param key="jbm.remoting.netty.useservlet" value="true" type="Boolean"/>
+ </connector>
<connector name="in-vm">
<factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
Modified: trunk/src/config/jbm-jms.xml
===================================================================
--- trunk/src/config/jbm-jms.xml 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/config/jbm-jms.xml 2009-02-28 14:58:12 UTC (rev 5949)
@@ -91,6 +91,11 @@
<entry name="/TestHttpConnectionFactory"/>
</connection-factory>
+ <connection-factory name="TestServletConnectionFactory">
+ <connector-ref connector-name="netty-servlet"/>
+ <entry name="/TestServletConnectionFactory"/>
+ </connection-factory>
+
<queue name="MyQueue">
<entry name="MyQueue"/>
</queue>
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-02-28 14:58:12 UTC (rev 5949)
@@ -22,19 +22,6 @@
package org.jboss.messaging.integration.transports.netty;
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import java.net.InetSocketAddress;
-import java.util.Map;
-import java.util.Timer;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLContext;
-
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
@@ -55,13 +42,27 @@
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
+import static org.jboss.netty.channel.Channels.pipeline;
import org.jboss.netty.channel.group.DefaultChannelGroup;
+import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory;
+import org.jboss.netty.channel.local.LocalAddress;
+import org.jboss.netty.channel.local.LocalServerChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.ssl.SslHandler;
+import javax.net.ssl.SSLContext;
+import java.net.InetSocketAddress;
+import java.util.Map;
+import java.util.Timer;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
/**
* A Netty TCP Acceptor that supports SSL
*
@@ -119,9 +120,13 @@
private final Timer httpKeepAliveTimer;
private final HttpKeepAliveTask httpKeepAliveTask;
-
+
private ConcurrentMap<Object, Connection> connections = new ConcurrentHashMap<Object, Connection>();
+ private Channel localChannel;
+
+ private int inVmServerId;
+
public NettyAcceptor(final Map<String, Object> configuration,
final BufferHandler handler,
final ConnectionLifeCycleListener listener)
@@ -198,6 +203,8 @@
TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE,
configuration);
+
+ inVmServerId = ConfigurationHelper.getIntProperty(org.jboss.messaging.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, 0, configuration);
}
public synchronized void start() throws Exception
@@ -240,7 +247,7 @@
context = null; // Unused
}
- bootstrap.setPipelineFactory(new ChannelPipelineFactory()
+ ChannelPipelineFactory factory = new ChannelPipelineFactory()
{
public ChannelPipeline getPipeline() throws Exception
{
@@ -260,7 +267,8 @@
pipeline.addLast("handler", new MessagingServerChannelHandler(handler, listener));
return pipeline;
}
- });
+ };
+ bootstrap.setPipelineFactory(factory);
// Bind
bootstrap.setOption("child.tcpNoDelay", tcpNoDelay);
@@ -277,17 +285,23 @@
bootstrap.setOption("child.keepAlive", true);
serverChannelGroup = new DefaultChannelGroup("jbm");
-
+
String[] hosts = TransportConfiguration.splitHosts(host);
for (String h : hosts)
{
Channel serverChannel = bootstrap.bind(new InetSocketAddress(h, port));
serverChannelGroup.add(serverChannel);
}
+ LocalServerChannelFactory localServerChannelFactory = new DefaultLocalServerChannelFactory();
+ ServerBootstrap localBoot = new ServerBootstrap(localServerChannelFactory);
+ localBoot.setPipelineFactory(factory);
+ LocalAddress localAddress = new LocalAddress("org.jboss.jbm." + inVmServerId);
+ localChannel = localBoot.bind(localAddress);
}
public synchronized void stop()
{
+
if (channelFactory == null)
{
return;
@@ -299,6 +313,7 @@
httpKeepAliveTimer.cancel();
}
+ localChannel.unbind();
serverChannelGroup.close().awaitUninterruptibly();
bossExecutor.shutdown();
workerExecutor.shutdown();
@@ -317,7 +332,7 @@
}
}
channelFactory = null;
-
+
for (Connection connection : connections.values())
{
listener.connectionDestroyed(connection.getID());
@@ -325,7 +340,7 @@
connections.clear();
}
-
+
public boolean isStarted()
{
return (channelFactory != null);
@@ -343,9 +358,9 @@
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
- {
+ {
final Connection tc = new NettyConnection(e.getChannel(), new Listener());
-
+
SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
if (sslHandler != null)
{
@@ -372,7 +387,7 @@
}
}
}
-
+
private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final Connection connection)
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-02-28 14:58:12 UTC (rev 5949)
@@ -21,22 +21,6 @@
*/
package org.jboss.messaging.integration.transports.netty;
-import static org.jboss.netty.channel.Channels.pipeline;
-import static org.jboss.netty.channel.Channels.write;
-
-import java.net.InetSocketAddress;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.ssl.SSLSupport;
@@ -45,6 +29,7 @@
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.core.remoting.spi.Connector;
import org.jboss.messaging.utils.ConfigurationHelper;
+import org.jboss.messaging.utils.Future;
import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -56,11 +41,19 @@
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
+import static org.jboss.netty.channel.Channels.pipeline;
+import static org.jboss.netty.channel.Channels.write;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.UpstreamMessageEvent;
+import org.jboss.netty.channel.socket.ClientSocketChannelFactory;
+import org.jboss.netty.channel.socket.http.HttpTunnelAddress;
+import org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
+import org.jboss.netty.handler.codec.http.Cookie;
+import org.jboss.netty.handler.codec.http.CookieDecoder;
+import org.jboss.netty.handler.codec.http.CookieEncoder;
import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpMethod;
@@ -71,6 +64,21 @@
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.ssl.SslHandler;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
/**
* A NettyConnector
*
@@ -105,8 +113,12 @@
private final long httpClientIdleScanPeriod;
+ private final boolean httpRequiresSessionId;
+
private final boolean useNio;
+ private final boolean useServlet;
+
private final String host;
private final int port;
@@ -120,9 +132,11 @@
private final int tcpSendBufferSize;
private final int tcpReceiveBufferSize;
-
+
private ConcurrentMap<Object, Connection> connections = new ConcurrentHashMap<Object, Connection>();
+ private static final String SERVLET_PATH = "/messaging/JBMServlet";
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -153,7 +167,7 @@
this.httpEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_ENABLED_PROP_NAME,
TransportConstants.DEFAULT_HTTP_ENABLED,
configuration);
-
+
if (httpEnabled)
{
this.httpMaxClientIdleTime = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME,
@@ -162,16 +176,23 @@
this.httpClientIdleScanPeriod = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD,
TransportConstants.DEFAULT_HTTP_CLIENT_SCAN_PERIOD,
configuration);
+ this.httpRequiresSessionId = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_REQUIRES_SESSION_ID,
+ TransportConstants.DEFAULT_HTTP_REQUIRES_SESSION_ID,
+ configuration);
}
else
{
this.httpMaxClientIdleTime = 0;
this.httpClientIdleScanPeriod = -1;
+ this.httpRequiresSessionId = false;
}
this.useNio = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_NIO_PROP_NAME,
TransportConstants.DEFAULT_USE_NIO,
configuration);
+ this.useServlet = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_SERVLET_PROP_NAME,
+ TransportConstants.DEFAULT_USE_SERVLET,
+ configuration);
this.host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME,
TransportConstants.DEFAULT_HOST,
configuration);
@@ -203,6 +224,7 @@
TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE,
configuration);
+
}
public synchronized void start()
@@ -211,13 +233,32 @@
{
return;
}
-
- workerExecutor = Executors.newCachedThreadPool(new org.jboss.messaging.utils.JBMThreadFactory("jbm-netty-connector-worker-threads"));
- if (useNio)
+
+ workerExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-worker-threads"));
+ if (useServlet)
{
bossExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-boss-threads"));
+
+
+ ClientSocketChannelFactory proxyChannelFactory;
+ if(useNio)
+ {
+ bossExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-boss-threads"));
+ proxyChannelFactory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
+ }
+ else
+ {
+ proxyChannelFactory = new OioClientSocketChannelFactory(workerExecutor);
+ }
+ channelFactory = new HttpTunnelingClientSocketChannelFactory(proxyChannelFactory, workerExecutor);
+
+ }
+ else if (useNio)
+ {
+ bossExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-boss-threads"));
channelFactory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
}
+
else
{
channelFactory = new OioClientSocketChannelFactory(workerExecutor);
@@ -294,7 +335,7 @@
workerExecutor.shutdown();
if (bossExecutor != null)
{
- for (;;)
+ for (; ;)
{
try
{
@@ -309,7 +350,7 @@
}
}
}
-
+
for (Connection connection : connections.values())
{
listener.connectionDestroyed(connection.getID());
@@ -317,7 +358,7 @@
connections.clear();
}
-
+
public boolean isStarted()
{
return (channelFactory != null);
@@ -329,8 +370,23 @@
{
return null;
}
-
- InetSocketAddress address = new InetSocketAddress(host, port);
+ SocketAddress address;
+ if(useServlet)
+ {
+ try
+ {
+ URI uri = new URI("http", null, host, port, SERVLET_PATH, null, null);
+ address = new HttpTunnelAddress(uri);
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+ else
+ {
+ address = new InetSocketAddress(host, port);
+ }
ChannelFuture future = bootstrap.connect(address);
future.awaitUninterruptibly();
@@ -364,9 +420,9 @@
{
ch.getPipeline().get(MessagingChannelHandler.class).active = true;
}
-
+
NettyConnection conn = new NettyConnection(ch, new Listener());
-
+
return conn;
}
else
@@ -395,8 +451,8 @@
}
}
- @ChannelPipelineCoverage("all")
- private class HttpHandler extends SimpleChannelHandler
+ @ChannelPipelineCoverage("one")
+ class HttpHandler extends SimpleChannelHandler
{
private Channel channel;
@@ -408,10 +464,28 @@
private HttpIdleTimerTask task;
+ private String url;
+
+ //private String sessionId = null;
+
+ private Future handShakeFuture = new Future();
+
+ private boolean active = false;
+
+ private boolean handshaking = true;
+
+ private CookieDecoder cookieDecoder = new CookieDecoder();
+
+ private String cookie;
+
+ private CookieEncoder cookieEncoder = new CookieEncoder();
+
+
public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception
{
super.channelConnected(ctx, e);
channel = e.getChannel();
+ url = "http://" + host + ":" + port + "/messaging/JBMServlet";
if (httpClientIdleScanPeriod > 0)
{
idleClientTimer = new Timer("Http Idle Timer", true);
@@ -428,7 +502,7 @@
idleClientTimer.cancel();
}
-
+
super.channelClosed(ctx, e);
}
@@ -436,6 +510,18 @@
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception
{
HttpResponse response = (HttpResponse)e.getMessage();
+ if (httpRequiresSessionId && !active)
+ {
+ Map<String, Cookie> cookieMap = cookieDecoder.decode(response.getHeader(HttpHeaders.Names.SET_COOKIE));
+ Cookie cookie = cookieMap.get("JSESSIONID");
+ if(cookie != null)
+ {
+ cookieEncoder.addCookie(cookie);
+ this.cookie = cookieEncoder.encode();
+ }
+ active = true;
+ handShakeFuture.run();
+ }
MessageEvent event = new UpstreamMessageEvent(e.getChannel(),
response.getContent(),
e.getRemoteAddress());
@@ -448,8 +534,20 @@
{
if (e.getMessage() instanceof ChannelBuffer)
{
- HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/jbm/");
- ChannelBuffer buf = (ChannelBuffer)e.getMessage();
+ if (!active && handshaking)
+ {
+ handshaking = false;
+ if(!handShakeFuture.await(5000))
+ {
+ throw new RuntimeException("Handshake failed after timeout");
+ }
+ }
+ HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url);
+ if (cookie != null)
+ {
+ httpRequest.addHeader(HttpHeaders.Names.COOKIE, cookie);
+ }
+ ChannelBuffer buf = (ChannelBuffer) e.getMessage();
httpRequest.setContent(buf);
httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.writerIndex()));
write(ctx, e.getFuture(), httpRequest, e.getRemoteAddress());
@@ -465,11 +563,12 @@
private class HttpIdleTimerTask extends TimerTask
{
long currentTime = System.currentTimeMillis();
+
public synchronized void run()
{
if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime)
{
- HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/jbm/");
+ HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url);
waitingGet = true;
channel.write(httpRequest);
}
@@ -481,7 +580,7 @@
}
}
}
-
+
private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final Connection connection)
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/TransportConstants.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/TransportConstants.java 2009-02-27 20:23:47 UTC (rev 5948)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/TransportConstants.java 2009-02-28 14:58:12 UTC (rev 5949)
@@ -41,6 +41,10 @@
public static final String HTTP_SERVER_SCAN_PERIOD_PROP_NAME = "jbm.remoting.netty.httpserverscanperiod";
+ public static final String HTTP_REQUIRES_SESSION_ID = "jbm.remoting.netty.httprequiressessionid";
+
+ public static final String USE_SERVLET_PROP_NAME = "jbm.remoting.netty.useservlet";
+
public static final String USE_NIO_PROP_NAME = "jbm.remoting.netty.usenio";
public static final String HOST_PROP_NAME = "jbm.remoting.netty.host";
@@ -65,6 +69,8 @@
public static final boolean DEFAULT_USE_NIO = true;
+ public static final boolean DEFAULT_USE_SERVLET = false;
+
public static final String DEFAULT_HOST = "localhost";
public static final int DEFAULT_PORT = 5445;
@@ -93,4 +99,5 @@
public static final long DEFAULT_HTTP_SERVER_SCAN_PERIOD = 5000;
+ public static final boolean DEFAULT_HTTP_REQUIRES_SESSION_ID = false;
}
More information about the jboss-cvs-commits
mailing list