當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getJMSMessageID方法代碼示例

本文整理匯總了Java中javax.jms.Message.getJMSMessageID方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getJMSMessageID方法的具體用法?Java Message.getJMSMessageID怎麽用?Java Message.getJMSMessageID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.Message的用法示例。


在下文中一共展示了Message.getJMSMessageID方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkOrDeleteLockingPendingMessages

import javax.jms.Message; //導入方法依賴的package包/類
/** Browses all pending messages in the input queue looking for the locks, as specified in the input filter.
 * Throws an ApplicationException, if any matching message is found, and if the input argument 'deleteLockingMessage' is false.
 * Deletes all matching messages, if the input argument 'deleteLockingMessage' is true.
 * @param queueName the queue name.
 * @param filter the filter for retrieving Lock messages.
 * @param deleteLockingMessage determines if the matching messages are to be deleted.
 * @param session the JMS session.
 * @throws JMSException if any JMS error occurs.
 * @throws FrameworkException Indicates some system error.
 * @throws ApplicationExceptions Indicates application error(s).
 */
private static void checkOrDeleteLockingPendingMessages(String queueName, String filter, boolean deleteLockingMessage, Session session)
throws JMSException, ApplicationExceptions, FrameworkException {
    // Creates a QueueBrowser from the Session, using the filter
    if (log.isDebugEnabled())
        log.debug("Checking for locks in pending messages in " + queueName + " with the filter " + filter);
    QueueBrowser qb = session.createBrowser(JmsClientHelper.obtainQueue(queueName), filter);
    
    // Throws an ApplicationException if any applicable lock is found
    Enumeration e = qb.getEnumeration();
    while (e.hasMoreElements()) {
        Message message = (Message) e.nextElement();
        if (log.isDebugEnabled())
            log.debug("Found a blocking pending message in " + queueName + " with the contents " + message);
        if (deleteLockingMessage)
            JmsBrowser.consumeMessage(session, message, queueName);
        else
            throw new ApplicationExceptions(new JaffaMessagingApplicationException(JaffaMessagingApplicationException.LOCK_ERROR, new Object[] {queueName, message.getJMSMessageID()}));
    }
    
    // Close the QueueBrowser
    qb.close();
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:34,代碼來源:LockingService.java

示例2: getMessageIdForBusinessEventLog

import javax.jms.Message; //導入方法依賴的package包/類
/** Returns the messageId to be used for retrieving the BusinessEventLogs for a Message.
 * @param input The criteria based on which an object will be retrieved.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The messageId.
 */
public String getMessageIdForBusinessEventLog(MessageViewerInDto input) throws FrameworkException, ApplicationExceptions{
    try{
        Message message = findMessage(input);
        return message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID) != null ? message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID) : message.getJMSMessageID();
    } catch(JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:15,代碼來源:MessageViewerTx.java

示例3: getBeans

import javax.jms.Message; //導入方法依賴的package包/類
/**
 * Read the status beans from any queue.
 * Returns a list of optionally date-ordered beans in the queue.
 *
 * @param uri
 * @param queueName
 * @param clazz
 * @param monitor
 * @return
 * @throws Exception
 */
public List<T> getBeans(final URI uri, final String queueName, final Class<T> beanClass) throws Exception {

	QueueConnection qCon = null;
	try {
		QueueConnectionFactory connectionFactory = (QueueConnectionFactory)service.createConnectionFactory(uri);
		qCon  = connectionFactory.createQueueConnection(); // This times out when the server is not there.
		QueueSession    qSes  = qCon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
		Queue queue   = qSes.createQueue(queueName);
		qCon.start();

		QueueBrowser qb = qSes.createBrowser(queue);
		@SuppressWarnings("rawtypes")
		Enumeration  e  = qb.getEnumeration();


		final Collection<T> list;
		if (comparator!=null) {
			list = new TreeSet<T>(comparator);
		} else {
			list = new ArrayList<T>(17);
		}

		while(e.hasMoreElements()) {
			Message m = (Message)e.nextElement();
			if (m==null) continue;
			if (m instanceof TextMessage) {
				TextMessage t = (TextMessage)m;
				String json   = t.getText();
				@SuppressWarnings("unchecked")
				final Class<T> statusBeanClass = (Class<T>) StatusBean.class;
				try {
					final T bean = (T)service.unmarshal(json, beanClass != null ? beanClass : statusBeanClass);
					list.add(bean);

				} catch (Exception unmarshallable) {
					System.out.println("Removing old message "+json);
					String jMSMessageID = m.getJMSMessageID();
					if (jMSMessageID!=null) {
						MessageConsumer consumer = qSes.createConsumer(queue, "JMSMessageID = '"+jMSMessageID+"'");
						Message ignored = consumer.receive(1000);
						consumer.close();
						System.out.println("Removed");
					}

				}
			}
		}
		return list instanceof List ? (List<T>)list : new ArrayList<T>(list);

	} finally {
		if (qCon!=null) qCon.close();
	}

}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:66,代碼來源:QueueReader.java


注:本文中的javax.jms.Message.getJMSMessageID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。