protected void onStompDisconnect(StompFrame command) throws ProtocolException { if (connected.get()) { sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command)); sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command)); connected.set(false); } }
protected void onStompDisconnect(StompFrame command) throws ProtocolException { if (connected.get()) { sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command)); sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command)); connected.set(false); } }
protected void onStompDisconnect(StompFrame command) throws ProtocolException { if (connected.get()) { sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command)); sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command)); connected.set(false); } }
public ActiveMQDestination createTempQueue(String name) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { rc = new ActiveMQTempQueue(connectionId, tempDestinationGenerator.getNextSequenceId()); sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); } return rc; }
protected void onStompDisconnect(StompFrame command) throws ProtocolException { checkConnected(); sendToActiveMQ(connectionInfo.createRemoveCommand(), createResponseHandler(command)); sendToActiveMQ(new ShutdownInfo(), createResponseHandler(command)); connected.set(false); }
public ActiveMQDestination createTempTopic(String name) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { rc = new ActiveMQTempTopic(connectionId, tempDestinationGenerator.getNextSequenceId()); sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); tempDestinationAmqToStompMap.put(rc.getQualifiedName(), name); } return rc; }
public ActiveMQDestination createTempDestination(String name, boolean topic) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { if (topic) { rc = new ActiveMQTempTopic(connectionId, tempDestinationGenerator.getNextSequenceId()); } else { rc = new ActiveMQTempQueue(connectionId, tempDestinationGenerator.getNextSequenceId()); } sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); tempDestinationAmqToStompMap.put(rc.getQualifiedName(), name); } return rc; }
public ActiveMQDestination createTempDestination(String name, boolean topic) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { if (topic) { rc = new ActiveMQTempTopic(connectionId, tempDestinationGenerator.getNextSequenceId()); } else { rc = new ActiveMQTempQueue(connectionId, tempDestinationGenerator.getNextSequenceId()); } sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); tempDestinationAmqToStompMap.put(rc.getQualifiedName(), name); } return rc; }
public ActiveMQDestination createTempDestination(String name, boolean topic) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { if (topic) { rc = new ActiveMQTempTopic(connectionId, tempDestinationGenerator.getNextSequenceId()); } else { rc = new ActiveMQTempQueue(connectionId, tempDestinationGenerator.getNextSequenceId()); } sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); tempDestinationAmqToStompMap.put(rc.getQualifiedName(), name); } return rc; }
protected void onStompCommit(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (Iterator<StompSubscription> iter = subscriptionsByConsumerId.values().iterator(); iter.hasNext();) { StompSubscription sub = iter.next(); sub.onStompCommit(activemqTx); } TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompCommit(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (StompSubscription sub : subscriptionsByConsumerId.values()) { sub.onStompCommit(activemqTx); } pedingAcks.clear(); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompCommit(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (StompSubscription sub : subscriptionsByConsumerId.values()) { sub.onStompCommit(activemqTx); } pedingAcks.clear(); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was already started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was already started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was allready started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was already started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompSend(StompFrame command) throws IOException, JMSException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); headers.remove("transaction"); ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); MessageId id = new MessageId(producerId, messageIdGenerator.getNextSequenceId()); message.setMessageId(id); message.setJMSTimestamp(System.currentTimeMillis()); if (stompTx != null) { TransactionId activemqTx = transactions.get(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } message.setTransactionId(activemqTx); } message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
protected void onStompSend(StompFrame command) throws IOException, JMSException { checkConnected(); Map<String, String> headers = command.getHeaders(); String destination = headers.get(Stomp.Headers.Send.DESTINATION); if (destination == null) { throw new ProtocolException("SEND received without a Destination specified!"); } String stompTx = headers.get(Stomp.Headers.TRANSACTION); headers.remove("transaction"); ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); MessageId id = new MessageId(producerId, messageIdGenerator.getNextSequenceId()); message.setMessageId(id); if (stompTx != null) { TransactionId activemqTx = transactions.get(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } message.setTransactionId(activemqTx); } message.onSend(); message.beforeMarshall(null); sendToActiveMQ(message, createResponseHandler(command)); }
protected void onStompSend(StompFrame command) throws IOException, JMSException { checkConnected(); Map<String, String> headers = command.getHeaders(); String destination = headers.get(Stomp.Headers.Send.DESTINATION); if (destination == null) { throw new ProtocolException("SEND received without a Destination specified!"); } String stompTx = headers.get(Stomp.Headers.TRANSACTION); headers.remove("transaction"); ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); MessageId id = new MessageId(producerId, messageIdGenerator.getNextSequenceId()); message.setMessageId(id); if (stompTx != null) { TransactionId activemqTx = transactions.get(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } message.setTransactionId(activemqTx); } message.onSend(); message.beforeMarshall(null); sendToActiveMQ(message, createResponseHandler(command)); }
@Override public void onResponse(ProtocolConverter converter, Response response) throws IOException { if (response.isException()) { // Generally a command can fail.. but that does not invalidate the connection. // We report back the failure but we don't close the connection. Throwable exception = ((ExceptionResponse)response).getException(); handleException(exception, cmd); } else { StompFrame sc = new StompFrame(); sc.setAction(Stomp.Responses.RECEIPT); sc.setHeaders(new HashMap<String, String>(1)); sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId); stompTransport.sendToStomp(sc); ConsumerControl control = new ConsumerControl(); control.setPrefetch(prefetch); control.setDestination(actualDest); control.setConsumerId(id); sendToActiveMQ(control, null); } } };