List of usage examples for javax.jms IllegalStateException IllegalStateException
public IllegalStateException(String reason)
From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java
@Override public final void recover() throws JMSException { if (transacted) throw new IllegalStateException("Session is transacted"); // [JMS SPEC] externalAccessLock.readLock().lock(); try {/*from w w w .ja v a2s . c o m*/ checkNotClosed(); RecoverQuery query = new RecoverQuery(); query.setSessionId(id); query.setDeliveredMessageIDs(deliveredMessageIDs); transportEndpoint.blockingRequest(query); deliveredMessageIDs.clear(); synchronousAckRequired = false; } finally { externalAccessLock.readLock().unlock(); } }
From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java
@Override public final void commit() throws JMSException { if (!transacted) throw new IllegalStateException("Session is not transacted"); // [JMS SPEC] log.debug("#" + id + " commit()"); externalAccessLock.readLock().lock(); try {/*from w ww .jav a 2 s . c o m*/ checkNotClosed(); final CommitQuery query = new CommitQuery(); query.setSessionId(id); query.setDeliveredMessageIDs(deliveredMessageIDs); if (retryOnQueueFull) retriableBlockingQuery(query, retryTimeout); else transportEndpoint.blockingRequest(query); deliveredMessageIDs.clear(); } finally { externalAccessLock.readLock().unlock(); } }
From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java
private void retriableBlockingQuery(AbstractQueryPacket query, long retryTimeout) throws JMSException { long retryWait = 50; // ms long totalWait = 0; while (true) { try {//from ww w . j a v a 2s .c o m transportEndpoint.blockingRequest(query); break; } catch (DataStoreFullException e) { if (retryTimeout <= 0 || totalWait < retryTimeout) { // Release lock during passive wait externalAccessLock.readLock().unlock(); try { synchronized (retryLock) { retryLock.wait(retryWait); } } catch (InterruptedException ex) { // Interrupted --> give up immediatly throw e; } finally { // Re-acquire lock during passive wait externalAccessLock.readLock().lock(); } // Concurrently closed ? if (closed) throw new IllegalStateException("Session is closed"); // Update total wait time totalWait += retryWait; // Exponential wait delay growth if (totalWait < retryTimeout) { retryWait = retryWait * 2; if (retryWait > 2000) retryWait = 2000; if (retryWait > retryTimeout - totalWait) retryWait = retryTimeout - totalWait; } continue; // Try again } // Give up ... throw e; } } }
From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java
@Override public final void rollback() throws JMSException { if (!transacted) throw new IllegalStateException("Session is not transacted"); // [JMS SPEC] log.debug("#" + id + " rollback()"); externalAccessLock.readLock().lock(); try {/*from ww w. j a v a2 s.co m*/ checkNotClosed(); RollbackQuery query = new RollbackQuery(); query.setSessionId(id); query.setDeliveredMessageIDs(deliveredMessageIDs); transportEndpoint.blockingRequest(query); deliveredMessageIDs.clear(); } finally { externalAccessLock.readLock().unlock(); } }
From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java
@Override public final void acknowledge() throws JMSException { if (transacted) throw new IllegalStateException("Session is transacted"); // [JMS SPEC] externalAccessLock.readLock().lock(); try {/*from ww w. j a va2 s .co m*/ checkNotClosed(); if (deliveredMessageIDs.isEmpty()) throw new FFMQException("No received message to acknowledge", "INTERNAL_ERROR"); if (sendAcksAsync && !synchronousAckRequired) { // Copy message list List<String> messageIDs = new ArrayList<>(deliveredMessageIDs.size()); for (int n = 0; n < deliveredMessageIDs.size(); n++) messageIDs.add(deliveredMessageIDs.get(n)); deliveredMessageIDs.clear(); AcknowledgeQuery query = new AcknowledgeQuery(); query.setSessionId(id); query.setDeliveredMessageIDs(messageIDs); transportEndpoint.nonBlockingRequest(query); } else { AcknowledgeQuery query = new AcknowledgeQuery(); query.setSessionId(id); query.setDeliveredMessageIDs(deliveredMessageIDs); transportEndpoint.blockingRequest(query); deliveredMessageIDs.clear(); } synchronousAckRequired = false; } finally { externalAccessLock.readLock().unlock(); } }
From source file:org.apache.activemq.jms.pool.ConnectionPool.java
public Session createSession(boolean transacted, int ackMode) throws JMSException { SessionKey key = new SessionKey(transacted, ackMode); PooledSession session;/*ww w. ja va2s . co m*/ try { session = new PooledSession(key, sessionPool.borrowObject(key), sessionPool, key.isTransacted(), useAnonymousProducers); session.addSessionEventListener(new PooledSessionEventListener() { @Override public void onTemporaryTopicCreate(TemporaryTopic tempTopic) { } @Override public void onTemporaryQueueCreate(TemporaryQueue tempQueue) { } @Override public void onSessionClosed(PooledSession session) { ConnectionPool.this.loanedSessions.remove(session); } }); this.loanedSessions.add(session); } catch (Exception e) { IllegalStateException illegalStateException = new IllegalStateException(e.toString()); illegalStateException.initCause(e); throw illegalStateException; } return session; }
From source file:org.apache.aries.transaction.jms.internal.ConnectionPool.java
public Session createSession(boolean transacted, int ackMode) throws JMSException { SessionKey key = new SessionKey(transacted, ackMode); PooledSession session;// www .j a va 2s . c o m try { session = sessionPool.borrowObject(key); } catch (Exception e) { javax.jms.IllegalStateException illegalStateException = new IllegalStateException(e.toString()); illegalStateException.initCause(e); throw illegalStateException; } return session; }
From source file:org.apache.karaf.jms.pool.internal.ConnectionPool.java
public Session createSession(boolean transacted, int ackMode) throws JMSException { SessionKey key = new SessionKey(transacted, ackMode); PooledSession session;//from w w w. j a v a 2 s .c o m try { session = sessionPool.borrowObject(key); } catch (Exception e) { IllegalStateException illegalStateException = new IllegalStateException(e.toString()); illegalStateException.initCause(e); throw illegalStateException; } return session; }
From source file:org.apache.rocketmq.jms.RocketMQConnection.java
@Override public void setClientID(String clientID) throws JMSException { if (isNotBlank(this.clientID)) { throw new IllegalStateException("administratively client identifier has been configured."); }/*from w ww . j av a 2 s .co m*/ this.clientID = clientID; }
From source file:org.broadleafcommerce.core.search.service.solr.SolrConfiguration.java
/** * Sets the primary SolrClient instance to communicate with Solr. This is typically one of the following: * <code>org.apache.solr.client.solrj.embedded.EmbeddedSolrClient</code>, * <code>org.apache.solr.client.solrj.impl.HttpSolrClient</code>, * <code>org.apache.solr.client.solrj.impl.LBHttpSolrClient</code>, * or <code>org.apache.solr.client.solrj.impl.CloudSolrClient</code> * /*from ww w . j a v a 2s .c om*/ * @param server * @throws IllegalStateException */ public void setServer(SolrClient server) throws IllegalStateException { if (server != null && CloudSolrClient.class.isAssignableFrom(server.getClass())) { CloudSolrClient cs = (CloudSolrClient) server; if (StringUtils.isBlank(cs.getDefaultCollection())) { cs.setDefaultCollection(getPrimaryName()); } if (reindexServer != null) { //If we already have a reindex server set, make sure it's not the same instance as the primary if (server == reindexServer) { throw new IllegalArgumentException( "The primary and reindex CloudSolrServers are the same instances. " + "They must be different instances. Each instance must have a different defaultCollection or " + "the defaultCollection must be unspecified and Broadleaf will set it."); } if (CloudSolrClient.class.isAssignableFrom(reindexServer.getClass())) { //Make sure that the primary and reindex servers are not using the same default collection name if (cs.getDefaultCollection() .equals(((CloudSolrClient) reindexServer).getDefaultCollection())) { throw new IllegalStateException( "Primary and Reindex servers cannot have the same defaultCollection: " + cs.getDefaultCollection()); } } } } primaryServer = server; }