当前位置: 首页>>代码示例>>Java>>正文


Java JmsUtils.closeMessageConsumer方法代码示例

本文整理汇总了Java中org.springframework.jms.support.JmsUtils.closeMessageConsumer方法的典型用法代码示例。如果您正苦于以下问题:Java JmsUtils.closeMessageConsumer方法的具体用法?Java JmsUtils.closeMessageConsumer怎么用?Java JmsUtils.closeMessageConsumer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jms.support.JmsUtils的用法示例。


在下文中一共展示了JmsUtils.closeMessageConsumer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearResources

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
private void clearResources() {
	if (sharedConnectionEnabled()) {
		synchronized (sharedConnectionMonitor) {
			JmsUtils.closeMessageConsumer(this.consumer);
			JmsUtils.closeSession(this.session);
		}
	}
	else {
		JmsUtils.closeMessageConsumer(this.consumer);
		JmsUtils.closeSession(this.session);
	}
	if (this.consumer != null) {
		synchronized (lifecycleMonitor) {
			registeredWithDestination--;
		}
	}
	this.consumer = null;
	this.session = null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:DefaultMessageListenerContainer.java

示例2: doShutdown

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Destroy the registered JMS Sessions and associated MessageConsumers.
 */
@Override
protected void doShutdown() throws JMSException {
	synchronized (this.consumersMonitor) {
		if (this.consumers != null) {
			logger.debug("Closing JMS MessageConsumers");
			for (MessageConsumer consumer : this.consumers) {
				JmsUtils.closeMessageConsumer(consumer);
			}
			logger.debug("Closing JMS Sessions");
			for (Session session : this.sessions) {
				JmsUtils.closeSession(session);
			}
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:SimpleMessageListenerContainer.java

示例3: doExecuteRequest

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Actually execute the given request, sending the invoker request message
 * to the specified target queue and waiting for a corresponding response.
 * <p>The default implementation is based on standard JMS send/receive,
 * using a {@link javax.jms.TemporaryQueue} for receiving the response.
 * @param session the JMS Session to use
 * @param queue the resolved target Queue to send to
 * @param requestMessage the JMS Message to send
 * @return the RemoteInvocationResult object
 * @throws JMSException in case of JMS failure
 */
protected Message doExecuteRequest(Session session, Queue queue, Message requestMessage) throws JMSException {
	TemporaryQueue responseQueue = null;
	MessageProducer producer = null;
	MessageConsumer consumer = null;
	try {
		responseQueue = session.createTemporaryQueue();
		producer = session.createProducer(queue);
		consumer = session.createConsumer(responseQueue);
		requestMessage.setJMSReplyTo(responseQueue);
		producer.send(requestMessage);
		long timeout = getReceiveTimeout();
		return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
	}
	finally {
		JmsUtils.closeMessageConsumer(consumer);
		JmsUtils.closeMessageProducer(producer);
		if (responseQueue != null) {
			responseQueue.delete();
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:JmsInvokerClientInterceptor.java

示例4: getCloseAction

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
private Runnable getCloseAction(final String tickDistributionSpecification, final ConsumerRecord record) {
  return new Runnable() {
    
    @Override
    public void run() {
      record.getReceiving().remove(tickDistributionSpecification);
      if (record.getReceiving().isEmpty()) {
        s_logger.debug("Closing connection after last unsubscribe {}", tickDistributionSpecification);
        JmsUtils.closeMessageConsumer(record.getConsumer());
        for (String receiving : record.getAllReceiving()) {
          _messageConsumersBySpec.remove(receiving);
        }
      } else {
        //TODO: Should I shrink the subscription? 
        s_logger.debug("Not closing composite connection remaining subscribtions {}", record.getReceiving());
      }
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:ActiveMQLiveDataClient.java

示例5: doReceive

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Actually receive a JMS message.
 * @param session the JMS Session to operate on
 * @param consumer the JMS MessageConsumer to receive with
 * @return the JMS Message received, or {@code null} if none
 * @throws JMSException if thrown by JMS API methods
 */
protected Message doReceive(Session session, MessageConsumer consumer) throws JMSException {
	try {
		// Use transaction timeout (if available).
		long timeout = getReceiveTimeout();
		JmsResourceHolder resourceHolder =
				(JmsResourceHolder) TransactionSynchronizationManager.getResource(getConnectionFactory());
		if (resourceHolder != null && resourceHolder.hasTimeout()) {
			timeout = Math.min(timeout, resourceHolder.getTimeToLiveInMillis());
		}
		Message message = doReceive(consumer, timeout);
		if (session.getTransacted()) {
			// Commit necessary - but avoid commit call within a JTA transaction.
			if (isSessionLocallyTransacted(session)) {
				// Transacted session created by this template -> commit.
				JmsUtils.commitIfNecessary(session);
			}
		}
		else if (isClientAcknowledge(session)) {
			// Manually acknowledge message, if any.
			if (message != null) {
				message.acknowledge();
			}
		}
		return message;
	}
	finally {
		JmsUtils.closeMessageConsumer(consumer);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:37,代码来源:JmsTemplate.java

示例6: doSendAndReceive

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Send a request message to the given {@link Destination} and block until
 * a reply has been received on a temporary queue created on-the-fly.
 * <p>Return the response message or {@code null} if no message has
 * @throws JMSException if thrown by JMS API methods
 */
protected Message doSendAndReceive(Session session, Destination destination, MessageCreator messageCreator)
		throws JMSException {

	Assert.notNull(messageCreator, "MessageCreator must not be null");
	TemporaryQueue responseQueue = null;
	MessageProducer producer = null;
	MessageConsumer consumer = null;
	try {
		Message requestMessage = messageCreator.createMessage(session);
		responseQueue = session.createTemporaryQueue();
		producer = session.createProducer(destination);
		consumer = session.createConsumer(responseQueue);
		requestMessage.setJMSReplyTo(responseQueue);
		if (logger.isDebugEnabled()) {
			logger.debug("Sending created message: " + requestMessage);
		}
		doSend(producer, requestMessage);
		return doReceive(consumer, getReceiveTimeout());
	}
	finally {
		JmsUtils.closeMessageConsumer(consumer);
		JmsUtils.closeMessageProducer(producer);
		if (responseQueue != null) {
			responseQueue.delete();
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:JmsTemplate.java

示例7: getCloseAction

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
private Runnable getCloseAction(final String tickDistributionSpecification, final MessageConsumer messageConsumer) {
  return new Runnable() {
    @Override
    public void run() {
      JmsUtils.closeMessageConsumer(messageConsumer);
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:9,代码来源:JmsLiveDataClient.java

示例8: doExecuteRequest

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Actually execute the given request, sending the invoker request message
 * to the specified target queue and waiting for a corresponding response.
 * <p>The default implementation is based on standard JMS send/receive,
 * using a {@link javax.jms.TemporaryQueue} for receiving the response.
 * @param session the JMS Session to use
 * @param queue the resolved target Queue to send to
 * @param requestMessage the JMS Message to send
 * @return the RemoteInvocationResult object
 * @throws JMSException in case of JMS failure
 */
protected Message doExecuteRequest(Session session, Queue queue, Message requestMessage) throws JMSException {
	TemporaryQueue responseQueue = null;
	MessageProducer producer = null;
	MessageConsumer consumer = null;
	try {
		if (jms11Available) {
			// Standard JMS 1.1 API usage...
			responseQueue = session.createTemporaryQueue();
			producer = session.createProducer(queue);
			consumer = session.createConsumer(responseQueue);
			requestMessage.setJMSReplyTo(responseQueue);
			producer.send(requestMessage);
		}
		else {
			// Perform all calls on QueueSession reference for JMS 1.0.2 compatibility...
			// DEPRECATED but kept around with the deprecated JmsTemplate102 etc classes for the time being.
			QueueSession queueSession = (QueueSession) session;
			responseQueue = queueSession.createTemporaryQueue();
			QueueSender sender = queueSession.createSender(queue);
			producer = sender;
			consumer = queueSession.createReceiver(responseQueue);
			requestMessage.setJMSReplyTo(responseQueue);
			sender.send(requestMessage);
		}
		long timeout = getReceiveTimeout();
		return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
	}
	finally {
		JmsUtils.closeMessageConsumer(consumer);
		JmsUtils.closeMessageProducer(producer);
		if (responseQueue != null) {
			responseQueue.delete();
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:47,代码来源:JmsInvokerClientInterceptor.java

示例9: doBatchReceive

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
protected List<Message> doBatchReceive(Session session, MessageConsumer consumer, int batchSize)
        throws JMSException {

    try {
        final List<Message> result;
        long timeout = determineTimeout();

        Message message = doReceive(consumer, timeout);

        if (message == null) {
            result = new ArrayList<Message>(0);
        } else {
            result = new ArrayList<Message>(batchSize);
            result.add(message);
            for (int i = 1; i < batchSize; i++) {
                message = doReceive(consumer, RECEIVE_TIMEOUT_NO_WAIT);
                if (message == null) {
                    break;
                }
                result.add(message);
            }
        }

        if (session.getTransacted()) {
            if (isSessionLocallyTransacted(session)) {
                JmsUtils.commitIfNecessary(session);
            }
        } else if (isClientAcknowledge(session)) {
            if (message != null) {
                message.acknowledge();
            }
        }
        return result;
    } finally {
        JmsUtils.closeMessageConsumer(consumer);
    }
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:38,代码来源:BatchedJmsTemplate.java

示例10: doSingleReceive

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
protected Message doSingleReceive(Session session, MessageConsumer consumer) throws JMSException {

        if (!session.getTransacted() || isSessionLocallyTransacted(session)) {
            // If we are not using JTA we should use standard JmsTemplate behaviour
            return super.doReceive(session, consumer);
        }

        // Otherwise batching - the batch can span multiple receive() calls, until you commit the
        // batch
        try {
            final Message message;
            if (Boolean.TRUE.equals(IS_START_OF_BATCH.get())) {
                // Register Synchronization
                TransactionSynchronizationManager.registerSynchronization(BATCH_SYNCHRONIZATION);

                // Use transaction timeout (if available).
                long timeout = determineTimeout();

                message = doReceive(consumer, timeout);
                IS_START_OF_BATCH.set(Boolean.FALSE);
            } else {
                message = doReceive(consumer, RECEIVE_TIMEOUT_NO_WAIT);
            }

            if (isClientAcknowledge(session)) {
                // Manually acknowledge message, if any.
                if (message != null) {
                    message.acknowledge();
                }
            }
            return message;
        } finally {
            JmsUtils.closeMessageConsumer(consumer);
        }
    }
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:36,代码来源:BatchedJmsTemplate.java

示例11: close

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
public void close() throws JMSException {
  JmsUtils.closeMessageConsumer(_consumer);
  JmsUtils.closeSession(_session);
  _connection.close();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:6,代码来源:JmsTemporaryQueueHost.java


注:本文中的org.springframework.jms.support.JmsUtils.closeMessageConsumer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。