mirror of https://github.com/apache/activemq.git
a couple of Stomp improvements
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@741109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c22cd6563b
commit
690b7bcbd1
|
@ -161,7 +161,7 @@ public class ProtocolConverter {
|
||||||
*
|
*
|
||||||
* @param command
|
* @param command
|
||||||
*/
|
*/
|
||||||
public void onStompCommad(StompFrame command) throws IOException, JMSException {
|
public void onStompCommand(StompFrame command) throws IOException, JMSException {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (command.getClass() == StompFrameError.class) {
|
if (command.getClass() == StompFrameError.class) {
|
||||||
|
@ -459,6 +459,8 @@ public class ProtocolConverter {
|
||||||
throw new ProtocolException("No subscription matched.");
|
throw new ProtocolException("No subscription matched.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConnectionInfo connectionInfo = new ConnectionInfo();
|
||||||
|
|
||||||
protected void onStompConnect(final StompFrame command) throws ProtocolException {
|
protected void onStompConnect(final StompFrame command) throws ProtocolException {
|
||||||
|
|
||||||
if (connected.get()) {
|
if (connected.get()) {
|
||||||
|
@ -472,7 +474,6 @@ public class ProtocolConverter {
|
||||||
String passcode = headers.get(Stomp.Headers.Connect.PASSCODE);
|
String passcode = headers.get(Stomp.Headers.Connect.PASSCODE);
|
||||||
String clientId = headers.get(Stomp.Headers.Connect.CLIENT_ID);
|
String clientId = headers.get(Stomp.Headers.Connect.CLIENT_ID);
|
||||||
|
|
||||||
final ConnectionInfo connectionInfo = new ConnectionInfo();
|
|
||||||
|
|
||||||
IntrospectionSupport.setProperties(connectionInfo, headers, "activemq.");
|
IntrospectionSupport.setProperties(connectionInfo, headers, "activemq.");
|
||||||
|
|
||||||
|
@ -540,6 +541,7 @@ public class ProtocolConverter {
|
||||||
|
|
||||||
protected void onStompDisconnect(StompFrame command) throws ProtocolException {
|
protected void onStompDisconnect(StompFrame command) throws ProtocolException {
|
||||||
checkConnected();
|
checkConnected();
|
||||||
|
sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command));
|
||||||
sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command));
|
sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command));
|
||||||
connected.set(false);
|
connected.set(false);
|
||||||
}
|
}
|
||||||
|
@ -556,7 +558,7 @@ public class ProtocolConverter {
|
||||||
* @param command
|
* @param command
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void onActiveMQCommad(Command command) throws IOException, JMSException {
|
public void onActiveMQCommand(Command command) throws IOException, JMSException {
|
||||||
if (command.isResponse()) {
|
if (command.isResponse()) {
|
||||||
|
|
||||||
Response response = (Response)command;
|
Response response = (Response)command;
|
||||||
|
|
|
@ -107,9 +107,16 @@ public class StompConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(String username, String password) throws Exception {
|
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<String, String> headers = new HashMap();
|
HashMap<String, String> headers = new HashMap();
|
||||||
headers.put("login", username);
|
headers.put("login", username);
|
||||||
headers.put("passcode", password);
|
headers.put("passcode", password);
|
||||||
|
if (client != null) {
|
||||||
|
headers.put("client-id", client);
|
||||||
|
}
|
||||||
StompFrame frame = new StompFrame("CONNECT", headers);
|
StompFrame frame = new StompFrame("CONNECT", headers);
|
||||||
sendFrame(frame.toString());
|
sendFrame(frame.toString());
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class StompTransportFilter extends TransportFilter {
|
||||||
public void oneway(Object o) throws IOException {
|
public void oneway(Object o) throws IOException {
|
||||||
try {
|
try {
|
||||||
final Command command = (Command)o;
|
final Command command = (Command)o;
|
||||||
protocolConverter.onActiveMQCommad(command);
|
protocolConverter.onActiveMQCommand(command);
|
||||||
} catch (JMSException e) {
|
} catch (JMSException e) {
|
||||||
throw IOExceptionSupport.create(e);
|
throw IOExceptionSupport.create(e);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class StompTransportFilter extends TransportFilter {
|
||||||
if (trace) {
|
if (trace) {
|
||||||
LOG.trace("Received: \n" + command);
|
LOG.trace("Received: \n" + command);
|
||||||
}
|
}
|
||||||
protocolConverter.onStompCommad((StompFrame)command);
|
protocolConverter.onStompCommand((StompFrame)command);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
onException(e);
|
onException(e);
|
||||||
} catch (JMSException e) {
|
} catch (JMSException e) {
|
||||||
|
|
Loading…
Reference in New Issue