use of javax.jms.IllegalStateException in project activemq-artemis by apache.
the class AmqpTransactionCoordinator method declare.
public void declare(AmqpTransactionId txId, AsyncResult request) throws Exception {
if (txId.getRemoteTxId() != null) {
throw new IllegalStateException("Declare called while a TX is still Active.");
}
if (isClosed()) {
request.onFailure(new JMSException("Cannot start new transaction: Coordinator remotely closed"));
return;
}
Message message = Message.Factory.create();
Declare declare = new Declare();
message.setBody(new AmqpValue(declare));
Delivery pendingDelivery = getEndpoint().delivery(tagGenerator.getNextTag());
pendingDelivery.setContext(txId);
// Store away for completion
pendingDeliveries.add(pendingDelivery);
pendingRequests.put(txId, request);
sendTxCommand(message);
}
use of javax.jms.IllegalStateException in project activemq-artemis by apache.
the class AmqpTransactionCoordinator method processDeliveryUpdates.
@Override
public void processDeliveryUpdates(AmqpConnection connection, Delivery delivery) throws IOException {
try {
Iterator<Delivery> deliveries = pendingDeliveries.iterator();
while (deliveries.hasNext()) {
Delivery pendingDelivery = deliveries.next();
if (!pendingDelivery.remotelySettled()) {
continue;
}
DeliveryState state = pendingDelivery.getRemoteState();
AmqpTransactionId txId = (AmqpTransactionId) pendingDelivery.getContext();
AsyncResult pendingRequest = pendingRequests.get(txId);
if (pendingRequest == null) {
throw new IllegalStateException("Pending tx operation with no pending request");
}
if (state instanceof Declared) {
LOG.debug("New TX started: {}", txId.getTxId());
Declared declared = (Declared) state;
txId.setRemoteTxId(declared.getTxnId());
pendingRequest.onSuccess();
} else if (state instanceof Rejected) {
LOG.debug("Last TX request failed: {}", txId.getTxId());
Rejected rejected = (Rejected) state;
Exception cause = AmqpSupport.convertToException(rejected.getError());
JMSException failureCause = null;
if (txId.isCommit()) {
failureCause = new TransactionRolledBackException(cause.getMessage());
} else {
failureCause = new JMSException(cause.getMessage());
}
pendingRequest.onFailure(failureCause);
} else {
LOG.debug("Last TX request succeeded: {}", txId.getTxId());
pendingRequest.onSuccess();
}
// Clear state data
pendingDelivery.settle();
pendingRequests.remove(txId);
deliveries.remove();
}
super.processDeliveryUpdates(connection, delivery);
} catch (Exception e) {
throw IOExceptionSupport.create(e);
}
}
use of javax.jms.IllegalStateException in project BroadleafCommerce by BroadleafCommerce.
the class SolrHelperServiceImpl method swapActiveCores.
/**
* This should only ever be called when using the Solr reindex service to do a full reindex.
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
@Override
public synchronized void swapActiveCores(SolrConfiguration solrConfiguration) throws ServiceException {
if (!isSolrConfigured) {
return;
}
if (CloudSolrClient.class.isAssignableFrom(solrConfiguration.getServer().getClass()) && CloudSolrClient.class.isAssignableFrom(solrConfiguration.getReindexServer().getClass())) {
CloudSolrClient primaryCloudClient = (CloudSolrClient) solrConfiguration.getServer();
CloudSolrClient reindexCloudClient = (CloudSolrClient) solrConfiguration.getReindexServer();
try {
primaryCloudClient.connect();
Aliases aliases = primaryCloudClient.getZkStateReader().getAliases();
Map<String, String> aliasCollectionMap = aliases.getCollectionAliasMap();
if (aliasCollectionMap == null || !aliasCollectionMap.containsKey(primaryCloudClient.getDefaultCollection()) || !aliasCollectionMap.containsKey(reindexCloudClient.getDefaultCollection())) {
throw new IllegalStateException("Could not determine the PRIMARY or REINDEX " + "collection or collections from the Solr aliases.");
}
String primaryCollectionName = aliasCollectionMap.get(primaryCloudClient.getDefaultCollection());
// Do this just in case primary is aliased to more than one collection
primaryCollectionName = primaryCollectionName.split(",")[0];
String reindexCollectionName = aliasCollectionMap.get(reindexCloudClient.getDefaultCollection());
// Do this just in case primary is aliased to more than one collection
reindexCollectionName = reindexCollectionName.split(",")[0];
// Essentially "swap cores" here by reassigning the aliases
new CollectionAdminRequest.CreateAlias().setAliasName(primaryCloudClient.getDefaultCollection()).setAliasedCollections(reindexCollectionName).process(primaryCloudClient);
new CollectionAdminRequest.CreateAlias().setAliasName(reindexCloudClient.getDefaultCollection()).setAliasedCollections(primaryCollectionName).process(reindexCloudClient);
} catch (Exception e) {
LOG.error("An exception occured swapping cores.", e);
throw new ServiceException("Unable to swap SolrCloud collections after a full reindex.", e);
}
} else {
if (solrConfiguration.getReindexServer() == null || solrConfiguration.getServer() == solrConfiguration.getReindexServer()) {
LOG.debug("In single core mode. There are no cores to swap.");
} else {
LOG.debug("Swapping active cores");
String primaryCoreName = solrConfiguration.getPrimaryName();
String reindexCoreName = solrConfiguration.getReindexName();
if (!StringUtils.isEmpty(primaryCoreName) && !StringUtils.isEmpty(reindexCoreName)) {
CoreAdminRequest car = new CoreAdminRequest();
car.setCoreName(primaryCoreName);
car.setOtherCoreName(reindexCoreName);
car.setAction(CoreAdminAction.SWAP);
try {
solrConfiguration.getAdminServer().request(car);
} catch (Exception e) {
LOG.error(e);
throw new ServiceException("Unable to swap cores", e);
}
} else {
LOG.error("Could not determine core names for the Solr Clients provided");
throw new ServiceException("Unable to swap cores");
}
}
}
}
use of javax.jms.IllegalStateException in project aries by apache.
the class ConnectionPool method createSession.
public Session createSession(boolean transacted, int ackMode) throws JMSException {
SessionKey key = new SessionKey(transacted, ackMode);
PooledSession session;
try {
session = sessionPool.borrowObject(key);
} catch (Exception e) {
javax.jms.IllegalStateException illegalStateException = new IllegalStateException(e.toString());
illegalStateException.initCause(e);
throw illegalStateException;
}
return session;
}
Aggregations