i have checked the source code of org.hornetq.core.protocol.stomp.StompSession and i find that when the server gets the SUBSCRIBE command, it will get the exist session or create a new session （if not exist）and start it to make the comsumer to revieve message. the method "addSubscription" in StompSession:
session.createConsumer(consumerID, queue, SimpleString.toSimpleString(selector), false); session.receiveConsumerCredits(consumerID, -1); StompSubscription subscription = new StompSubscription(subscriptionID, ack); subscriptions.put(consumerID, subscription); // FIXME not very smart: since we can't start the consumer, we start the session // every time to start the new consumer (and all previous consumers...) session.start();
if every StompSession only allow once SUBSCRIBE command,it goes well. but suppose that if i continuely send SUBSCRIBE and UNSUBSCRIBE command in once Connect , there is some problems. because the first geting SUBSCRIBE, StompSession starts the session and it dose not close the session until it recieve the DISCONNECT command. So this may result that : the subsequent SUBSCRIBE command makes the new created Consumer immediately recieve messages after
when the message arrives, these codes
maybe not be executed . so when the method "sendMessage" maybe throw a NullPointException.
so my quese tion is that :when server gets UNSUBSCRIBE command .should we stop the session first. is this a bug ?
no response? will anyone answer me about this?