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


Java Session.createBrowser方法代碼示例

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


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

示例1: browseMessages

import javax.jms.Session; //導入方法依賴的package包/類
/**
 * Browse messages using Queue Browser.
 * By default, you browse all actual messages in the queue.
 * Messages may be arriving and expiring while the scan is done.
 */
void browseMessages() throws Exception {
    Connection conn = createConnection(clientOptions);
    Session ssn = createSession(clientOptions, conn, transacted);
    QueueBrowser qBrowser = ssn.createBrowser((Queue) getDestination(), msgSelector);
    conn.start();
    Enumeration<?> enumMsgs = qBrowser.getEnumeration();
    while (enumMsgs.hasMoreElements()) {
        Message msg = (Message) enumMsgs.nextElement();
        printMessage(clientOptions, msg);
    }
    close(conn);
}
 
開發者ID:rh-messaging,項目名稱:cli-java,代碼行數:18,代碼來源:MessageBrowser.java

示例2: checkOrDeleteLockingPendingMessages

import javax.jms.Session; //導入方法依賴的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


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