当前位置: 首页>>代码示例>>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;未经允许,请勿转载。