mirror of https://github.com/apache/activemq.git
Modifed version of patch supplied by Claudio Parodi to handle incoming ping frames correctly.
This commit is contained in:
parent
b9ed01fa56
commit
516c9db43b
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.activemq.command.Command;
|
||||
import org.apache.activemq.command.KeepAliveInfo;
|
||||
import org.apache.activemq.transport.TransportSupport;
|
||||
import org.apache.activemq.transport.stomp.ProtocolConverter;
|
||||
import org.apache.activemq.transport.stomp.Stomp;
|
||||
|
@ -44,7 +45,7 @@ class StompSocket extends TransportSupport implements WebSocket.OnTextMessage, S
|
|||
ProtocolConverter protocolConverter = new ProtocolConverter(this, null);
|
||||
StompWireFormat wireFormat = new StompWireFormat();
|
||||
private final CountDownLatch socketTransportStarted = new CountDownLatch(1);
|
||||
private StompInactivityMonitor stompInactivityMonitor = new StompInactivityMonitor(this, wireFormat);
|
||||
private final StompInactivityMonitor stompInactivityMonitor = new StompInactivityMonitor(this, wireFormat);
|
||||
|
||||
@Override
|
||||
public void onOpen(Connection connection) {
|
||||
|
@ -74,7 +75,13 @@ class StompSocket extends TransportSupport implements WebSocket.OnTextMessage, S
|
|||
|
||||
|
||||
try {
|
||||
protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
|
||||
if (data != null) {
|
||||
if (data.startsWith("\n")) {
|
||||
sendToActiveMQ(new KeepAliveInfo());
|
||||
}
|
||||
|
||||
protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
onException(IOExceptionSupport.create(e));
|
||||
}
|
||||
|
@ -87,6 +94,7 @@ class StompSocket extends TransportSupport implements WebSocket.OnTextMessage, S
|
|||
@Override
|
||||
protected void doStart() throws Exception {
|
||||
socketTransportStarted.countDown();
|
||||
stompInactivityMonitor.setTransportListener(getTransportListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.activemq.command.Command;
|
||||
import org.apache.activemq.command.KeepAliveInfo;
|
||||
import org.apache.activemq.transport.TransportSupport;
|
||||
import org.apache.activemq.transport.stomp.ProtocolConverter;
|
||||
import org.apache.activemq.transport.stomp.Stomp;
|
||||
|
@ -45,7 +46,7 @@ class StompSocket extends TransportSupport implements WebSocketListener, StompTr
|
|||
ProtocolConverter protocolConverter = new ProtocolConverter(this, null);
|
||||
StompWireFormat wireFormat = new StompWireFormat();
|
||||
private final CountDownLatch socketTransportStarted = new CountDownLatch(1);
|
||||
private StompInactivityMonitor stompInactivityMonitor = new StompInactivityMonitor(this, wireFormat);
|
||||
private final StompInactivityMonitor stompInactivityMonitor = new StompInactivityMonitor(this, wireFormat);
|
||||
|
||||
private boolean transportStartedAtLeastOnce() {
|
||||
return socketTransportStarted.getCount() == 0;
|
||||
|
@ -54,6 +55,7 @@ class StompSocket extends TransportSupport implements WebSocketListener, StompTr
|
|||
@Override
|
||||
protected void doStart() throws Exception {
|
||||
socketTransportStarted.countDown();
|
||||
stompInactivityMonitor.setTransportListener(getTransportListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +120,7 @@ class StompSocket extends TransportSupport implements WebSocketListener, StompTr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketError(Throwable arg0) {
|
||||
public void onWebSocketError(Throwable arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,10 +135,15 @@ class StompSocket extends TransportSupport implements WebSocketListener, StompTr
|
|||
}
|
||||
|
||||
try {
|
||||
protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
|
||||
if (data != null) {
|
||||
if (data.startsWith("\n")) {
|
||||
sendToActiveMQ(new KeepAliveInfo());
|
||||
}
|
||||
|
||||
protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
onException(IOExceptionSupport.create(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.store.kahadb.KahaDBStore;
|
||||
|
||||
public class IDERunner {
|
||||
|
||||
private static final boolean TRANSPORT_TRACE = true;
|
||||
|
||||
public static void main(String[]args) throws Exception {
|
||||
BrokerService brokerService = new BrokerService();
|
||||
|
||||
brokerService.addConnector(
|
||||
"ws://0.0.0.0:61614?trace=" + TRANSPORT_TRACE);
|
||||
|
||||
KahaDBStore store = new KahaDBStore();
|
||||
store.setDirectory(new File("target/activemq-data/kahadb"));
|
||||
|
||||
brokerService.setStoreOpenWireVersion(10);
|
||||
brokerService.setPersistenceAdapter(store);
|
||||
brokerService.setUseJmx(false);
|
||||
brokerService.deleteAllMessages();
|
||||
|
||||
brokerService.start();
|
||||
brokerService.waitUntilStopped();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue