/** * Send the synchronous command. * * @param command - command to be executed. * @return Response * @throws JMSException */ public Response syncSendPacket(Command command) throws JMSException { return connection.syncSendPacket(command); }
/** * Send a packet through a Connection - for internal use only * * @param command * * @return the broker Response for the given Command. * * @throws JMSException */ public Response syncSendPacket(Command command) throws JMSException { return syncSendPacket(command, 0); }
/** * Create a ConnectionConsumer * * @param theConnection * @param theSessionPool * @param theConsumerInfo * @throws JMSException */ protected ActiveMQConnectionConsumer(ActiveMQConnection theConnection, ServerSessionPool theSessionPool, ConsumerInfo theConsumerInfo) throws JMSException { this.connection = theConnection; this.sessionPool = theSessionPool; this.consumerInfo = theConsumerInfo; this.connection.addConnectionConsumer(this); this.connection.addDispatcher(consumerInfo.getConsumerId(), this); this.connection.syncSendPacket(this.consumerInfo); }
public void doCleanup(boolean removeConnection) throws JMSException { if (advisoryConsumer != null && !isTransportFailed()) { advisoryConsumer.dispose(); advisoryConsumer = null; } for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();) { ActiveMQSession s = i.next(); s.dispose(); } for (Iterator<ActiveMQConnectionConsumer> i = this.connectionConsumers.iterator(); i.hasNext();) { ActiveMQConnectionConsumer c = i.next(); c.dispose(); } if (removeConnection) { if (isConnectionInfoSentToBroker) { if (!transportFailed.get() && !closing.get()) { syncSendPacket(info.createRemoveCommand()); } isConnectionInfoSentToBroker = false; } if (userSpecifiedClientID) { info.setClientId(null); userSpecifiedClientID = false; } clientIDSet = false; } started.set(false); }
@Override public Xid[] recover(int flag) throws XAException { LOG.debug("recover({})", flag); XATransactionId[] answer; if (XAResource.TMNOFLAGS == flag) { // signal next in cursor scan, which for us is always the end b/c we don't maintain any cursor state // allows looping scan to complete answer = new XATransactionId[0]; } else { TransactionInfo info = new TransactionInfo(getConnectionId(), null, TransactionInfo.RECOVER); try { this.connection.checkClosedOrFailed(); this.connection.ensureConnectionInfoSent(); DataArrayResponse receipt = (DataArrayResponse) this.connection.syncSendPacket(info); DataStructure[] data = receipt.getData(); if (data instanceof XATransactionId[]) { answer = (XATransactionId[]) data; } else { answer = new XATransactionId[data.length]; System.arraycopy(data, 0, answer, 0, data.length); } } catch (JMSException e) { throw toXAException(e); } } LOG.debug("recover({})={}", flag, answer); return answer; }
@Override public void forget(Xid xid) throws XAException { LOG.debug("Forget: {}", xid); // We allow interleaving multiple transactions, so // we don't limit forget to the associated xid. XATransactionId x; if (xid == null) { throw new XAException(XAException.XAER_PROTO); } if (equals(associatedXid, xid)) { // TODO determine if this can happen... I think not. x = (XATransactionId)transactionId; } else { x = new XATransactionId(xid); } TransactionInfo info = new TransactionInfo(getConnectionId(), x, TransactionInfo.FORGET); try { // Tell the server to forget the transaction. this.connection.syncSendPacket(info); } catch (JMSException e) { throw toXAException(e); } synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { ENDED_XA_TRANSACTION_CONTEXTS.remove(x); } }
IntegerResponse response = (IntegerResponse)this.connection.syncSendPacket(info); if (XAResource.XA_RDONLY == response.getResult()) {
this.connection.syncSendPacket(info);
this.transactionId = null; this.connection.syncSendPacket(info, this.connection.isClosing() ? this.connection.getCloseTimeout() : 0);
public AdvisoryConsumer(ActiveMQConnection connection, ConsumerId consumerId) throws JMSException { this.connection = connection; info = new ConsumerInfo(consumerId); info.setDestination(AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC); info.setPrefetchSize(1000); info.setNoLocal(true); info.setDispatchAsync(true); this.connection.addDispatcher(info.getConsumerId(), this); this.connection.syncSendPacket(this.info); }
this.connection.syncSendPacket(info);
TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.END); try { this.connection.syncSendPacket(info); LOG.debug("{} ended XA transaction {}", this, transactionId); } catch (JMSException e) {
/** * Send the ConnectionInfo to the Broker * * @throws JMSException */ protected void ensureConnectionInfoSent() throws JMSException { synchronized(this.ensureConnectionInfoSentMutex) { // Can we skip sending the ConnectionInfo packet?? if (isConnectionInfoSentToBroker || closed.get()) { return; } //TODO shouldn't this check be on userSpecifiedClientID rather than the value of clientID? if (info.getClientId() == null || info.getClientId().trim().length() == 0) { info.setClientId(clientIdGenerator.generateId()); } syncSendPacket(info.copy(), getConnectResponseTimeout()); this.isConnectionInfoSentToBroker = true; // Add a temp destination advisory consumer so that // We know what the valid temporary destinations are on the // broker without having to do an RPC to the broker. ConsumerId consumerId = new ConsumerId(new SessionId(info.getConnectionId(), -1), consumerIdGenerator.getNextSequenceId()); if (watchTopicAdvisories) { advisoryConsumer = new AdvisoryConsumer(this, consumerId); } } }
public void destroyDestination(ActiveMQDestination destination) throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE); info.setDestination(destination); info.setTimeout(0); syncSendPacket(info); }
syncSendPacket(command); } else { if (isClosed()) {
/** * @param destination * @throws JMSException */ public void deleteTempDestination(ActiveMQTempDestination destination) throws JMSException { checkClosedOrFailed(); for (ActiveMQSession session : this.sessions) { if (session.isInUse(destination)) { throw new JMSException("A consumer is consuming from the temporary destination"); } } activeTempDestinations.remove(destination); DestinationInfo destInfo = new DestinationInfo(); destInfo.setConnectionId(this.info.getConnectionId()); destInfo.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE); destInfo.setDestination(destination); destInfo.setTimeout(0); syncSendPacket(destInfo); }
this.connection.syncSendPacket(info); if (localTransactionEventListener != null) { localTransactionEventListener.commitEvent();
asyncSendPacket(msg); } else { syncSendPacket(msg);
/** * Create the DestinationInfo object for the temporary destination. * * @param topic - if its true topic, else queue. * @return DestinationInfo * @throws JMSException */ protected ActiveMQTempDestination createTempDestination(boolean topic) throws JMSException { // Check if Destination info is of temporary type. ActiveMQTempDestination dest; if (topic) { dest = new ActiveMQTempTopic(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } else { dest = new ActiveMQTempQueue(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE); info.setDestination(dest); syncSendPacket(info); dest.setConnection(this); activeTempDestinations.put(dest, dest); return dest; }
/** * Unsubscribes a durable subscription that has been created by a client. * <P> * This method deletes the state being maintained on behalf of the * subscriber by its provider. * <P> * It is erroneous for a client to delete a durable subscription while there * is an active <CODE>MessageConsumer </CODE> or * <CODE>TopicSubscriber</CODE> for the subscription, or while a consumed * message is part of a pending transaction or has not been acknowledged in * the session. * * @param name the name used to identify this subscription * @throws JMSException if the session fails to unsubscribe to the durable * subscription due to some internal error. * @throws InvalidDestinationException if an invalid subscription name is * specified. * @since 1.1 */ public void unsubscribe(String name) throws InvalidDestinationException, JMSException { checkClosedOrFailed(); RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo(); rsi.setConnectionId(getConnectionInfo().getConnectionId()); rsi.setSubscriptionName(name); rsi.setClientId(getConnectionInfo().getClientId()); syncSendPacket(rsi); }