From 690b7bcbd1f8da6a277e1c54da956c2c3768cc12 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Thu, 5 Feb 2009 14:33:59 +0000 Subject: [PATCH] a couple of Stomp improvements git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@741109 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/stomp/ProtocolConverter.java | 8 +++++--- .../apache/activemq/transport/stomp/StompConnection.java | 7 +++++++ .../activemq/transport/stomp/StompTransportFilter.java | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java index ed893d6f51..ffc398af72 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java @@ -161,7 +161,7 @@ public class ProtocolConverter { * * @param command */ - public void onStompCommad(StompFrame command) throws IOException, JMSException { + public void onStompCommand(StompFrame command) throws IOException, JMSException { try { if (command.getClass() == StompFrameError.class) { @@ -459,6 +459,8 @@ public class ProtocolConverter { throw new ProtocolException("No subscription matched."); } + ConnectionInfo connectionInfo = new ConnectionInfo(); + protected void onStompConnect(final StompFrame command) throws ProtocolException { if (connected.get()) { @@ -472,7 +474,6 @@ public class ProtocolConverter { String passcode = headers.get(Stomp.Headers.Connect.PASSCODE); String clientId = headers.get(Stomp.Headers.Connect.CLIENT_ID); - final ConnectionInfo connectionInfo = new ConnectionInfo(); IntrospectionSupport.setProperties(connectionInfo, headers, "activemq."); @@ -540,6 +541,7 @@ public class ProtocolConverter { protected void onStompDisconnect(StompFrame command) throws ProtocolException { checkConnected(); + sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command)); sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command)); connected.set(false); } @@ -556,7 +558,7 @@ public class ProtocolConverter { * @param command * @throws IOException */ - public void onActiveMQCommad(Command command) throws IOException, JMSException { + public void onActiveMQCommand(Command command) throws IOException, JMSException { if (command.isResponse()) { Response response = (Response)command; diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java index 1bd4bec2f0..db68061eaa 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java @@ -107,9 +107,16 @@ public class StompConnection { } public void connect(String username, String password) throws Exception { + connect(username, password, null); + } + + public void connect(String username, String password, String client) throws Exception { HashMap headers = new HashMap(); headers.put("login", username); headers.put("passcode", password); + if (client != null) { + headers.put("client-id", client); + } StompFrame frame = new StompFrame("CONNECT", headers); sendFrame(frame.toString()); diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java index a304012210..b963958730 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java @@ -53,7 +53,7 @@ public class StompTransportFilter extends TransportFilter { public void oneway(Object o) throws IOException { try { final Command command = (Command)o; - protocolConverter.onActiveMQCommad(command); + protocolConverter.onActiveMQCommand(command); } catch (JMSException e) { throw IOExceptionSupport.create(e); } @@ -64,7 +64,7 @@ public class StompTransportFilter extends TransportFilter { if (trace) { LOG.trace("Received: \n" + command); } - protocolConverter.onStompCommad((StompFrame)command); + protocolConverter.onStompCommand((StompFrame)command); } catch (IOException e) { onException(e); } catch (JMSException e) {