List of usage examples for javax.jms JMSException JMSException
public JMSException(String reason)
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override//ww w. ja v a2s .c om public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override/*from w ww . j a v a 2s .c om*/ public TemporaryQueue createTemporaryQueue() throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override//from w w w.j a v a 2 s.c om public TemporaryTopic createTemporaryTopic() throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override//from w ww .j a va2 s. c o m public MessageListener getMessageListener() throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override// w w w .j a v a 2 s . c om public void setMessageListener(MessageListener listener) throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override/* ww w. j a v a2s .co m*/ public StreamMessage createStreamMessage() throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:com.amazon.sqs.javamessaging.SQSSession.java
/** This method is not supported. */ @Override/*from w w w . j a va 2s .c om*/ public MapMessage createMapMessage() throws JMSException { throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD); }
From source file:net.timewalker.ffmq4.local.session.LocalSession.java
private void commitUpdates(boolean commitGets, List<String> deliveredMessageIDs, boolean commitPuts) throws JMSException { SynchronizationBarrier commitBarrier = null; List<LocalQueue> queuesWithGet = null; MessageLockSet locks = null;//from w w w . j a v a 2 s .c o m JMSException putFailure = null; Set<Committable> committables = new HashSet<>(); // 1 - Build a list of queues updated in get operations if (commitGets && transactionSet.size() > 0) { if (deliveredMessageIDs != null) queuesWithGet = transactionSet.updatedQueues(deliveredMessageIDs); else queuesWithGet = transactionSet.updatedQueues(); } // 2 - Build a list of all target destinations List<Committable> targetDestinations = computeLocalTargetDestinations(commitPuts ? pendingPuts : null, queuesWithGet); // 3 - Lock target destinations for (int i = 0; i < targetDestinations.size(); i++) { Committable committable = targetDestinations.get(i); committable.openTransaction(); } try { if (commitPuts) { // 4 - Try sending all pending queue messages first (because this may fail if a queue is full) synchronized (pendingPuts) { if (!pendingPuts.isEmpty()) { int pendingSize = pendingPuts.size(); locks = new MessageLockSet(pendingSize); if (debugEnabled) log.debug(this + " - COMMIT [PUT] " + pendingPuts.size() + " message(s)"); // Put messages in locked state. They will be unlocked after proper commit. try { for (int i = 0; i < pendingPuts.size(); i++) { AbstractMessage message = pendingPuts.get(i); AbstractLocalDestination targetDestination = getLocalDestination(message); if (targetDestination.putLocked(message, this, locks)) committables.add(targetDestination); } // All messages successfully pushed pendingPuts.clear(); } catch (JMSException e) { if (transacted) { // Oops, something went wrong, we need to rollback what we have done yet for (int i = 0; i < locks.size(); i++) { MessageLock item = locks.get(i); item.getDestination().removeLocked(item); } // Store failure (will be re-thrown later after transaction commit, see below) putFailure = e; } else ErrorTools.log(e, log); } producedCount += pendingSize; } } } // 5 - Commit pending get messages, i.e. delete them from destinations if (queuesWithGet != null && putFailure == null) { TransactionItem[] pendingGets; if (deliveredMessageIDs != null) { // Commit only delivered messages if (debugEnabled) log.debug(this + " - COMMIT [GET] " + deliveredMessageIDs.size() + " message(s)"); pendingGets = transactionSet.clear(deliveredMessageIDs); } else { // Commit the whole transaction set if (debugEnabled) log.debug(this + " - COMMIT [GET] " + transactionSet.size() + " message(s)"); pendingGets = transactionSet.clear(); } for (int i = 0; i < queuesWithGet.size(); i++) { LocalQueue localQueue = queuesWithGet.get(i); if (localQueue.remove(this, pendingGets)) committables.add(localQueue); consumedCount++; } } // 6 - Commit destinations if (committables.size() > 0) { commitBarrier = new SynchronizationBarrier(); Iterator<Committable> commitables = committables.iterator(); while (commitables.hasNext()) { Committable commitable = commitables.next(); commitable.commitChanges(commitBarrier); } } } finally { // 7 - Release locks for (int i = 0; i < targetDestinations.size(); i++) { Committable committable = targetDestinations.get(i); committable.closeTransaction(); } } // 8 - If something went wrong during put operations, stop here if (putFailure != null) throw putFailure; // 9 - Wait for commit barrier if necessary if (commitBarrier != null) { try { commitBarrier.waitFor(); } catch (InterruptedException e) { throw new JMSException("Commit barrier was interrupted"); } } // 10 - Unlock and deliver messages if (locks != null) { for (int i = 0; i < locks.size(); i++) { MessageLock item = locks.get(i); item.getDestination().unlockAndDeliver(item); } } }
From source file:net.timewalker.ffmq4.local.session.LocalSession.java
private void rollbackUpdates(boolean rollbackPuts, boolean rollbackGets, List<String> deliveredMessageIDs) throws JMSException { // Clear pending put messages if (rollbackPuts && transacted) { if (!pendingPuts.isEmpty()) { if (debugEnabled) log.debug(this + " - ROLLBACK [PUT] " + pendingPuts.size() + " message(s)"); pendingPuts.clear();/*from www . ja va 2s .c om*/ } } // Rollback pending get messages if (rollbackGets && transactionSet.size() > 0) { SynchronizationBarrier commitBarrier = null; Set<Committable> committables = new HashSet<>(); // 1 - Check for pending get operations TransactionItem[] pendingGets; if (deliveredMessageIDs != null) { // Rollback only delivered messages if (debugEnabled) log.debug(this + " - ROLLBACK [GET] " + deliveredMessageIDs.size() + " message(s)"); pendingGets = transactionSet.clear(deliveredMessageIDs); } else { // Rollback the whole transaction set if (debugEnabled) log.debug(this + " - ROLLBACK [GET] " + transactionSet.size() + " message(s)"); pendingGets = transactionSet.clear(); } List<LocalQueue> queuesWithGet = computeUpdatedQueues(pendingGets); MessageLockSet locks = new MessageLockSet(pendingGets.length); // 2 - Compute target destinations lists List<Committable> targetDestinations = computeLocalTargetDestinations(null, queuesWithGet); // 3 - Lock target destinations for (int i = 0; i < targetDestinations.size(); i++) { Committable committable = targetDestinations.get(i); committable.openTransaction(); } try { // 4 - Redeliver locked messages to queues for (int i = 0; i < queuesWithGet.size(); i++) { LocalQueue localQueue = queuesWithGet.get(i); if (localQueue.redeliverLocked(pendingGets, locks)) committables.add(localQueue); } // 5 - Commit destinations if (committables.size() > 0) { commitBarrier = new SynchronizationBarrier(); Iterator<Committable> commitables = committables.iterator(); while (commitables.hasNext()) { Committable commitable = commitables.next(); commitable.commitChanges(commitBarrier); } } } finally { // 6 - Release locks for (int i = 0; i < targetDestinations.size(); i++) { Committable committable = targetDestinations.get(i); committable.closeTransaction(); } } // 7 - Wait for commit barrier if necessary if (commitBarrier != null) { try { commitBarrier.waitFor(); } catch (InterruptedException e) { throw new JMSException("Commit barrier was interrupted"); } } // 8 - Unlock and re-deliver messages if necessary for (int i = 0; i < locks.size(); i++) { MessageLock item = locks.get(i); item.getDestination().unlockAndDeliver(item); } } }
From source file:nl.nn.adapterframework.extensions.tibco.GetTibcoQueues.java
private String getQueueMessage(Session jSession, TibjmsAdmin admin, String queueName, int queueItem, LdapSender ldapSender) throws TibjmsAdminException, JMSException { QueueInfo qInfo = admin.getQueue(queueName); if (qInfo == null) { throw new JMSException(" queue [" + queueName + "] does not exist"); }/* ww w .j a v a 2 s .c om*/ XmlBuilder qMessageXml = new XmlBuilder("qMessage"); ServerInfo serverInfo = admin.getInfo(); String url = serverInfo.getURL(); qMessageXml.addAttribute("url", url); String resolvedUrl = getResolvedUrl(url); if (resolvedUrl != null) { qMessageXml.addAttribute("resolvedUrl", resolvedUrl); } qMessageXml.addAttribute("timestamp", DateUtils.getIsoTimeStamp()); qMessageXml.addAttribute("startTime", DateUtils.format(serverInfo.getStartTime(), DateUtils.fullIsoFormat)); XmlBuilder qNameXml = new XmlBuilder("qName"); qNameXml.setCdataValue(queueName); Queue queue = jSession.createQueue(queueName); QueueBrowser queueBrowser = null; try { queueBrowser = jSession.createBrowser(queue); Enumeration enm = queueBrowser.getEnumeration(); int count = 0; boolean found = false; String chompCharSizeString = AppConstants.getInstance().getString("browseQueue.chompCharSize", null); int chompCharSize = (int) Misc.toFileSize(chompCharSizeString, -1); while (enm.hasMoreElements() && !found) { count++; if (count == queueItem) { qNameXml.addAttribute("item", count); Object o = enm.nextElement(); if (o instanceof Message) { Message msg = (Message) o; XmlBuilder qMessageId = new XmlBuilder("qMessageId"); qMessageId.setCdataValue(msg.getJMSMessageID()); qMessageXml.addSubElement(qMessageId); XmlBuilder qTimestamp = new XmlBuilder("qTimestamp"); qTimestamp.setCdataValue(DateUtils.format(msg.getJMSTimestamp(), DateUtils.fullIsoFormat)); qMessageXml.addSubElement(qTimestamp); StringBuffer sb = new StringBuffer(""); Enumeration propertyNames = msg.getPropertyNames(); while (propertyNames.hasMoreElements()) { String propertyName = (String) propertyNames.nextElement(); Object object = msg.getObjectProperty(propertyName); if (sb.length() > 0) { sb.append("; "); } sb.append(propertyName); sb.append("="); sb.append(object); } XmlBuilder qPropsXml = new XmlBuilder("qProps"); qPropsXml.setCdataValue(sb.toString()); qMessageXml.addSubElement(qPropsXml); XmlBuilder qTextXml = new XmlBuilder("qText"); String msgText; try { TextMessage textMessage = (TextMessage) msg; msgText = textMessage.getText(); } catch (ClassCastException e) { msgText = msg.toString(); qTextXml.addAttribute("text", false); } int msgSize = msgText.length(); if (isHideMessage()) { qTextXml.setCdataValue("***HIDDEN***"); } else { if (chompCharSize >= 0 && msgSize > chompCharSize) { qTextXml.setCdataValue(msgText.substring(0, chompCharSize) + "..."); qTextXml.addAttribute("chomped", true); } else { qTextXml.setCdataValue(msgText); } } qMessageXml.addSubElement(qTextXml); XmlBuilder qTextSizeXml = new XmlBuilder("qTextSize"); qTextSizeXml.setValue(Misc.toFileSize(msgSize)); qMessageXml.addSubElement(qTextSizeXml); } found = true; } else { enm.nextElement(); } } } finally { if (queueBrowser != null) { try { queueBrowser.close(); } catch (JMSException e) { log.warn(getLogPrefix(null) + "exception on closing queue browser", e); } } } qMessageXml.addSubElement(qNameXml); Map aclMap = getAclMap(admin, ldapSender); XmlBuilder aclXml = new XmlBuilder("acl"); XmlBuilder qInfoXml = qInfoToXml(qInfo); aclXml.setValue((String) aclMap.get(qInfo.getName())); qInfoXml.addSubElement(aclXml); qMessageXml.addSubElement(qInfoXml); Map consumersMap = getConnectedConsumersMap(admin); XmlBuilder consumerXml = new XmlBuilder("connectedConsumers"); if (consumersMap.containsKey(qInfo.getName())) { LinkedList<String> consumers = (LinkedList<String>) consumersMap.get(qInfo.getName()); String consumersString = listToString(consumers); if (consumersString != null) { consumerXml.setCdataValue(consumersString); } } qInfoXml.addSubElement(consumerXml); return qMessageXml.toXML(); }