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


Java QueueSender.close方法代碼示例

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


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

示例1: testGetQueue

import javax.jms.QueueSender; //導入方法依賴的package包/類
@Test
public void testGetQueue() throws JMSException {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createTemporaryQueue();
    QueueSender sender = session.createSender(queue);

    assertNotNull(sender.getQueue());
    assertSame(queue, sender.getQueue());

    sender.close();

    try {
        sender.getQueue();
        fail("Cannot read topic on closed sender");
    } catch (IllegalStateException ise) {}
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:18,代碼來源:JmsPoolQueueSenderTest.java

示例2: invokeJMS

import javax.jms.QueueSender; //導入方法依賴的package包/類
/** Send a JSON message to our notification queue.
 */
public void invokeJMS(JsonObject json) throws JMSException, NamingException {
	if (!initialized) initialize(); //gets our JMS managed resources (Q and QCF)

	QueueConnection connection = queueCF.createQueueConnection();
	QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

	TextMessage message = session.createTextMessage(json.toString());
	System.out.println("Sending "+json.toString()+" to "+queue.getQueueName());
	QueueSender sender = session.createSender(queue);
	sender.send(message);

	sender.close();
	session.close();
	connection.close();

	System.out.println("Message sent successfully!");
}
 
開發者ID:IBMStockTrader,項目名稱:loyalty-level,代碼行數:20,代碼來源:LoyaltyLevel.java

示例3: send

import javax.jms.QueueSender; //導入方法依賴的package包/類
/**
 * Sends a message to the myWMS application inside the application
 * server.
 * 
 * @param mfcMessage the message to be send
 * @throws JMSException
 * @throws NamingException
 */
public void send(MFCMessage mfcMessage)
    throws JMSException,
        NamingException
{

    // create the jms session
    QueueSession session =
        connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

    // lookup of the jms queue over jndi
    Queue outputQueue =
        (Queue) context.lookup("queue/" + OUTPUT_QUEUE_NAME);

    // create the message publisher
    QueueSender sender = session.createSender(outputQueue);

    ObjectMessage objectMessage = session.createObjectMessage();
    objectMessage.setObject(mfcMessage);
    objectMessage.setJMSTimestamp(System.currentTimeMillis());

    sender.send(objectMessage);
    sender.close();

    session.close();
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:34,代碼來源:ServerConnection.java

示例4: acknowledge

import javax.jms.QueueSender; //導入方法依賴的package包/類
private void acknowledge(Message jmsMessage, String msgid) throws JMSException, ServiceLocatorException {
        QueueConnection connection = null;
        QueueSession session = null;
        QueueSender sender = null;
        try {
            Queue respQueue = (Queue) jmsMessage.getJMSReplyTo();
            QueueConnectionFactory qcf = JMSServices.getInstance().getQueueConnectionFactory(null);
            connection = qcf.createQueueConnection();
            session = connection.createQueueSession(false, QueueSession.DUPS_OK_ACKNOWLEDGE);
            sender = session.createSender(respQueue);
            Message respMsg = session.createTextMessage(msgid);
//        respMsg.setJMSCorrelationID(correlationId); not used
            sender.send(respMsg);
        } finally {
            if (sender != null) sender.close();
            if (session != null) session.close();
            if (connection != null) connection.close();
        }
    }
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:20,代碼來源:InternalEventListener.java

示例5: sendReply

import javax.jms.QueueSender; //導入方法依賴的package包/類
/**
 * Intended for server-side reponse sending and implies that the received
 * message *always* contains a reply-to address.
 */
public void sendReply(QueueSession session, Message received_message, String response) throws IfsaException {
	QueueSender tqs=null;
    try {
        TextMessage answer = session.createTextMessage();
        answer.setText(response);
		Queue replyQueue = (Queue)received_message.getJMSReplyTo();
        tqs = session.createSender(replyQueue );
        if (log.isDebugEnabled()) log.debug(getLogPrefix()+ "sending reply to ["+ received_message.getJMSReplyTo()+ "]");
        ((IFSAServerQueueSender) tqs).sendReply(received_message, answer);
    } catch (Throwable t) {
        throw new IfsaException(t);
    } finally {
    	if (tqs!=null) {
			try {
				tqs.close();
			} catch (JMSException e) {
				log.warn(getLogPrefix()+ "exception closing reply queue sender",e);
			}	
    	}
    }
}
 
開發者ID:ibissource,項目名稱:iaf,代碼行數:26,代碼來源:IfsaFacade.java

示例6: closeResources

import javax.jms.QueueSender; //導入方法依賴的package包/類
private void closeResources(QueueConnection pConn, QueueSession pSession, QueueSender pSender)
        throws JMSException {
    if (pSender != null) {
        pSender.close();
    }
    if (pSession != null) {
        pSession.close();
    }
    if (pConn != null) {
        pConn.close();
    }
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:13,代碼來源:JMSServices.java

示例7: sendAMessage

import javax.jms.QueueSender; //導入方法依賴的package包/類
public void sendAMessage(String msg) throws JMSException {

        QueueSender send = session.createSender(que);
        TextMessage tm = session.createTextMessage(msg);

        send.send(tm);
        send.close();
    }
 
開發者ID:OpenRAP,項目名稱:jboss6-jms-chat,代碼行數:9,代碼來源:SendJMSMessage.java

示例8: run

import javax.jms.QueueSender; //導入方法依賴的package包/類
@Override
public void run()
   {
       super.run();
       
       try
       {
           QueueSender sender = getSession().createSender(queue);
           
           startSynchro.waitFor();
           
           for (int n = 0 ; n < messageCount ; n++)
           {
               variableWait();
               
               int msgPriority = (priority != -1) ? priority : random.nextInt(10);
               
               Message message = msgFactory.createDummyMessage(messageSize);
               sender.send(message, deliveryMode, msgPriority, timeToLive);
               if (transacted)
                   getSession().commit();
           }
           
           sender.close();
           //System.out.println(getName()+" thread complete ("+messageCount+" messages sent)");
       }
       catch (Throwable e)
       {
           inError = true;
           e.printStackTrace();
       }
   }
 
開發者ID:timewalker74,項目名稱:ffmq,代碼行數:33,代碼來源:QueueSenderThread.java

示例9: testMultipleCloseCallsNoErrors

import javax.jms.QueueSender; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testMultipleCloseCallsNoErrors() throws Exception {
    Queue queue = session.createQueue(getTestName());
    QueueSender sender = session.createSender(queue);
    sender.close();
    sender.close();
}
 
開發者ID:apache,項目名稱:qpid-jms,代碼行數:8,代碼來源:JmsQueueSenderTest.java

示例10: sendByQueue

import javax.jms.QueueSender; //導入方法依賴的package包/類
protected String sendByQueue(QueueSession session, Queue destination,
		Message message) throws NamingException, JMSException {
	QueueSender tqs = session.createSender(destination);
	tqs.send(message);
	tqs.close();
	return message.getJMSMessageID();
}
 
開發者ID:ibissource,項目名稱:iaf,代碼行數:8,代碼來源:JMSFacade.java

示例11: send

import javax.jms.QueueSender; //導入方法依賴的package包/類
public void send(String request) throws JMSException {
  TextMessage message = session.createTextMessage(request);
  message.setJMSReplyTo(responseQueue);
  QueueSender sender = null;
  try {
    sender = session.createSender(requestQueue);
    sender.send(message);
  } finally {
    if (sender != null) sender.close();
  }
}
 
開發者ID:tadayosi,項目名稱:samples-jbossws,代碼行數:12,代碼來源:JmsClient.java

示例12: close

import javax.jms.QueueSender; //導入方法依賴的package包/類
private void close(QueueSender queueSender) {
    if (queueSender != null) {
        try {
            queueSender.close();
        } catch (JMSException e) {
            LOG.error("Couldn't close QueueSender", e);
        }
    }
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:10,代碼來源:JmsJobSubmitter.java

示例13: sendRequest

import javax.jms.QueueSender; //導入方法依賴的package包/類
/**
 * Send an AnalysisRequest to the JMS request queue. Note this method does not store anything
 * in the cache. 
 * @throws JMSException 
 * @see sendRequest(Query query, AnalysisRequest request)
 */
public void sendRequest(AnalysisRequest request) throws JMSException {
	ObjectMessage msg;
	try {
		
		QueueSession requestSession = queueConnection.createQueueSession(
			      // No transaction
			      false,
			      // Auto ack
			      Session.AUTO_ACKNOWLEDGE);
		
	    // Create a message
		msg = requestSession.createObjectMessage(request);
		
		msg.setJMSReplyTo(resultQueue);
		
		QueueSender requestSender = requestSession.createSender(requestQueue);
		// Send the message
	    requestSender.send(msg, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
	    requestSender.close();
	    requestSession.close();
		logger.debug("sendRequest session: "+request.getSessionId()+" & task: "+request.getTaskId()+" has been sent to the JMQ");

	} catch (JMSException e) {
		logger.error(e);
		throw e;
	} 
}
 
開發者ID:NCIP,項目名稱:stats-application-commons,代碼行數:34,代碼來源:ZipFileJMSListener.java

示例14: sendRequest

import javax.jms.QueueSender; //導入方法依賴的package包/類
/**
 * Send an AnalysisRequest to the JMS request queue. Note this method does not store anything
 * in the cache. 
 * @throws JMSException 
 * @see sendRequest(Query query, AnalysisRequest request)
 */
public void sendRequest(final AnalysisRequest request) throws JMSException {
	ObjectMessage msg;
       
	try {
           if(managedBean) {
               queueConnection = queueConnectionFactory.createQueueConnection();
           }
	    
		QueueSession requestSession = queueConnection.createQueueSession(
			      // No transaction
			      false,
			      // Auto ack
			      Session.AUTO_ACKNOWLEDGE);
		
	    // Create a message
		msg = requestSession.createObjectMessage(request);
		
		msg.setJMSReplyTo(resultQueue);
		
		QueueSender requestSender = requestSession.createSender(requestQueue);
		// Send the message
	    requestSender.send(msg, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
	    requestSender.close();
	    requestSession.close();
           if(managedBean) {
               queueConnection.close();
           }
		logger.debug("sendRequest session: "+request.getSessionId()+" & task: "+request.getTaskId()+" has been sent to the JMQ");

	} catch (JMSException e) {
		logger.error(e);
		throw e;
	} 
}
 
開發者ID:NCIP,項目名稱:stats-application-commons,代碼行數:41,代碼來源:AnalysisServerClientManager.java

示例15: main

import javax.jms.QueueSender; //導入方法依賴的package包/類
public static void main(String[] args) {
  String queueConnectionFactoryName = "myjmsconnectionfactory"; //JMS Connection Factory的JNDI
  String queueName = "myjmsqueue"; //JMS Queue或者JMS Topic的JNDI
  boolean transacted = false;//transaction模式
  int acknowledgementMode = Session.AUTO_ACKNOWLEDGE;//acknowledgement模式
  String message="Message need to send";//模擬需要發送的消息
  Properties properties = new Properties();
  properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
  properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
  try {
    Context context = new InitialContext(properties);
    Object obj = context.lookup(queueConnectionFactoryName);
    QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;//JMS Connection Factory的獲得
   
    obj = context.lookup(queueName);
    Queue queue = (Queue) obj;//JMS Queue或者JMS Topic的獲得
    QueueConnection queueConnection=queueConnectionFactory.createQueueConnection();//產生連接
    queueConnection.start();
    QueueSession queueSession = queueConnection.createQueueSession(transacted, acknowledgementMode);
    TextMessage textMessage = queueSession.createTextMessage();
    textMessage.clearBody();
    textMessage.setText(message);
    QueueSender queueSender = queueSession.createSender(queue);
    
    queueSender.send(textMessage);
    if (transacted) {
      queueSession.commit();
    }
    if (queueSender != null) {
      queueSender.close();
    }
    if (queueSession != null) {
      queueSession.close();
    }
    if (queueConnection != null) {
      queueConnection.close();
    }
  }
  catch(Exception ex){
    ex.printStackTrace();
  }
}
 
開發者ID:dreajay,項目名稱:jcode,代碼行數:43,代碼來源:MessageProducter.java


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