Java Code Examples for javax.jms.QueueSender#close()

The following examples show how to use javax.jms.QueueSender#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsPoolQueueSenderTest.java    From pooled-jms with Apache License 2.0 6 votes vote down vote up
@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) {}
}
 
Example 2
Source File: IfsaFacade.java    From iaf with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
			}	
    	}
    }
}
 
Example 3
Source File: MDDProducer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void sendBytesMessage(String destName, byte[] buffer) throws Exception {

        InitialContext ic = getInitialContext();
        QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ic.lookup("ConnectionFactory");
        QueueConnection connection = queueConnectionFactory.createQueueConnection();
        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        BytesMessage bm = session.createBytesMessage();
        bm.writeBytes(buffer);
        QueueSender sender = session.createSender((Queue) ic.lookup(destName));
        sender.send(bm);
        sender.close();
        session.close();
        connection.close();
    }
 
Example 4
Source File: JmsQueueSenderTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 10000)
public void testMultipleCloseCallsNoErrors() throws Exception {
    Queue queue = session.createQueue(getTestName());
    QueueSender sender = session.createSender(queue);
    sender.close();
    sender.close();
}
 
Example 5
Source File: JMSFacade.java    From iaf with Apache License 2.0 4 votes vote down vote up
protected String sendByQueue(QueueSession session, Queue destination, javax.jms.Message message) throws NamingException, JMSException {
	QueueSender tqs = session.createSender(destination);
	tqs.send(message);
	tqs.close();
	return message.getJMSMessageID();
}