/** * Gets the metadata for this connection. * * @return the connection metadata * @throws JMSException if the JMS provider fails to get the connection * metadata for this connection. * @see javax.jms.ConnectionMetaData */ @Override public ConnectionMetaData getMetaData() throws JMSException { checkClosedOrFailed(); return ActiveMQConnectionMetaData.INSTANCE; }
/** * Gets the <CODE>ExceptionListener</CODE> object for this connection. Not * every <CODE>Connection</CODE> has an <CODE>ExceptionListener</CODE> * associated with it. * * @return the <CODE>ExceptionListener</CODE> for this connection, or * null, if no <CODE>ExceptionListener</CODE> is associated with * this connection. * @throws JMSException if the JMS provider fails to get the * <CODE>ExceptionListener</CODE> for this connection. * @see javax.jms.Connection#setExceptionListener(ExceptionListener) */ @Override public ExceptionListener getExceptionListener() throws JMSException { checkClosedOrFailed(); return this.exceptionListener; }
/** * Sets an exception listener for this connection. * <P> * If a JMS provider detects a serious problem with a connection, it informs * the connection's <CODE> ExceptionListener</CODE>, if one has been * registered. It does this by calling the listener's <CODE>onException * </CODE> * method, passing it a <CODE>JMSException</CODE> object describing the * problem. * <P> * An exception listener allows a client to be notified of a problem * asynchronously. Some connections only consume messages, so they would * have no other way to learn their connection has failed. * <P> * A connection serializes execution of its <CODE>ExceptionListener</CODE>. * <P> * A JMS provider should attempt to resolve connection problems itself * before it notifies the client of them. * * @param listener the exception listener * @throws JMSException if the JMS provider fails to set the exception * listener for this connection. */ @Override public void setExceptionListener(ExceptionListener listener) throws JMSException { checkClosedOrFailed(); this.exceptionListener = listener; }
/** * Gets the client identifier for this connection. * <P> * This value is specific to the JMS provider. It is either preconfigured by * an administrator in a <CODE> ConnectionFactory</CODE> object or assigned * dynamically by the application by calling the <code>setClientID</code> * method. * * @return the unique client identifier * @throws JMSException if the JMS provider fails to return the client ID * for this connection due to some internal error. */ @Override public String getClientID() throws JMSException { checkClosedOrFailed(); return this.info.getClientId(); }
/** * @see #stop() * @param checkClosed <tt>true</tt> to check for already closed and throw {@link java.lang.IllegalStateException} if already closed, * <tt>false</tt> to skip this check * @throws JMSException if the JMS provider fails to stop message delivery due to some internal error. */ void doStop(boolean checkClosed) throws JMSException { if (checkClosed) { checkClosedOrFailed(); } if (started.compareAndSet(true, false)) { synchronized(sessions) { for (Iterator<ActiveMQSession> i = sessions.iterator(); i.hasNext();) { ActiveMQSession s = i.next(); s.stop(); } } } }
/** * Starts (or restarts) a connection's delivery of incoming messages. A call * to <CODE>start</CODE> on a connection that has already been started is * ignored. * * @throws JMSException if the JMS provider fails to start message delivery * due to some internal error. * @see javax.jms.Connection#stop() */ @Override public void start() throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); if (started.compareAndSet(false, true)) { for (Iterator<ActiveMQSession> i = sessions.iterator(); i.hasNext();) { ActiveMQSession session = i.next(); session.start(); } } }
@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; }
this.connection.checkClosedOrFailed(); this.connection.ensureConnectionInfoSent();
this.connection.checkClosedOrFailed(); this.connection.ensureConnectionInfoSent();
private void setXid(Xid xid) throws XAException { this.connection.checkClosedOrFailed(); this.connection.ensureConnectionInfoSent(); } catch (JMSException e) {
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); }
/** * @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); }
checkClosedOrFailed(); ensureConnectionInfoSent(); if (!transacted) {
/** * 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); }
public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages, boolean noLocal) throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); ConsumerId consumerId = createConsumerId(); ConsumerInfo consumerInfo = new ConsumerInfo(consumerId); consumerInfo.setDestination(ActiveMQMessageTransformation.transformDestination(destination)); consumerInfo.setSelector(messageSelector); consumerInfo.setPrefetchSize(maxMessages); consumerInfo.setNoLocal(noLocal); consumerInfo.setDispatchAsync(isDispatchAsync()); // Allows the options on the destination to configure the consumerInfo if (consumerInfo.getDestination().getOptions() != null) { Map<String, String> options = new HashMap<>(consumerInfo.getDestination().getOptions()); IntrospectionSupport.setProperties(consumerInfo, options, "consumer."); } return new ActiveMQConnectionConsumer(this, sessionPool, consumerInfo); }
private InputStream doCreateInputStream(Destination dest, String messageSelector, boolean noLocal, String subName, long timeout) throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); return new ActiveMQInputStream(this, createConsumerId(), ActiveMQDestination.transform(dest), messageSelector, noLocal, subName, prefetchPolicy.getInputStreamPrefetch(), timeout); }
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); }