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


Java JmsUtils.closeMessageProducer方法代码示例

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


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

示例1: 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

示例2: doSend

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Send the given JMS message.
 * @param session the JMS Session to operate on
 * @param destination the JMS Destination to send to
 * @param messageCreator callback to create a JMS Message
 * @throws JMSException if thrown by JMS API methods
 */
protected void doSend(Session session, Destination destination, MessageCreator messageCreator)
		throws JMSException {

	Assert.notNull(messageCreator, "MessageCreator must not be null");
	MessageProducer producer = createProducer(session, destination);
	try {
		Message message = messageCreator.createMessage(session);
		if (logger.isDebugEnabled()) {
			logger.debug("Sending created message: " + message);
		}
		doSend(producer, message);
		// Check commit - avoid commit call within a JTA transaction.
		if (session.getTransacted() && isSessionLocallyTransacted(session)) {
			// Transacted session created by this template -> commit.
			JmsUtils.commitIfNecessary(session);
		}
	}
	finally {
		JmsUtils.closeMessageProducer(producer);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:JmsTemplate.java

示例3: doSendToDestination

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
private Object doSendToDestination(final Destination destination,
                                   final MessageCreator messageCreator,
                                   final MessageSentCallback callback,
                                   final Session session) throws JMSException {

    Assert.notNull(messageCreator, "MessageCreator must not be null");
    MessageProducer producer = createProducer(session, destination);
    Message message;
    try {
        message = messageCreator.createMessage(session);
        doSend(producer, message);
        if (message != null && callback != null) {
            callback.sent(session, message, destination);
        }
        // Check commit - avoid commit call within a JTA transaction.
        if (session.getTransacted() && isSessionLocallyTransacted(session)) {
            // Transacted session created by this template -> commit.
            JmsUtils.commitIfNecessary(session);
        }
    } finally {
        JmsUtils.closeMessageProducer(producer);
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:JmsConfiguration.java

示例4: sendResponse

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Overrides the superclass method to use the JMS 1.0.2 API to send a response.
 * <p>Uses the JMS pub-sub API if the given destination is a topic,
 * else uses the JMS queue API.
 */
protected void sendResponse(Session session, Destination destination, Message response) throws JMSException {
	MessageProducer producer = null;
	try {
		if (destination instanceof Topic) {
			producer = ((TopicSession) session).createPublisher((Topic) destination);
			postProcessProducer(producer, response);
			((TopicPublisher) producer).publish(response);
		}
		else {
			producer = ((QueueSession) session).createSender((Queue) destination);
			postProcessProducer(producer, response);
			((QueueSender) producer).send(response);
		}
	}
	finally {
		JmsUtils.closeMessageProducer(producer);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:MessageListenerAdapter102.java

示例5: sendResponse

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Send the given response message to the given destination.
 * @param response the JMS message to send
 * @param destination the JMS destination to send to
 * @param session the JMS session to operate on
 * @throws JMSException if thrown by JMS API methods
 * @see #postProcessProducer
 * @see javax.jms.Session#createProducer
 * @see javax.jms.MessageProducer#send
 */
protected void sendResponse(Session session, Destination destination, Message response) throws JMSException {
	MessageProducer producer = session.createProducer(destination);
	try {
		postProcessProducer(producer, response);
		producer.send(response);
	}
	finally {
		JmsUtils.closeMessageProducer(producer);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:AbstractAdaptableMessageListener.java

示例6: writeRemoteInvocationResult

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
/**
 * Send the given RemoteInvocationResult as a JMS message to the originator.
 * @param requestMessage current request message
 * @param session the JMS Session to use
 * @param result the RemoteInvocationResult object
 * @throws javax.jms.JMSException if thrown by trying to send the message
 */
protected void writeRemoteInvocationResult(
		Message requestMessage, Session session, RemoteInvocationResult result) throws JMSException {

	Message response = createResponseMessage(requestMessage, session, result);
	MessageProducer producer = session.createProducer(requestMessage.getJMSReplyTo());
	try {
		producer.send(response);
	}
	finally {
		JmsUtils.closeMessageProducer(producer);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:JmsInvokerServiceExporter.java

示例7: 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

示例8: closeJms

import org.springframework.jms.support.JmsUtils; //导入方法依赖的package包/类
private void closeJms() {
  if (_connection != null) {
    //[PLAT-1809] Need to close all of these
    JmsUtils.closeMessageProducer(_producer);
    JmsUtils.closeSession(_session);
    JmsUtils.closeConnection(_connection);

    _connection = null;
    _session = null;
    _producer = null;

  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:14,代码来源:AbstractJmsResultPublisher.java

示例9: 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


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