本文整理匯總了Java中javax.jms.QueueSession.createSender方法的典型用法代碼示例。如果您正苦於以下問題:Java QueueSession.createSender方法的具體用法?Java QueueSession.createSender怎麽用?Java QueueSession.createSender使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.QueueSession
的用法示例。
在下文中一共展示了QueueSession.createSender方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTestCreateQueueSender
import javax.jms.QueueSession; //導入方法依賴的package包/類
private void doTestCreateQueueSender(boolean useAnonymousProducers) throws JMSException {
cf.setUseAnonymousProducers(useAnonymousProducers);
JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue1 = session.createTemporaryQueue();
Queue queue2 = session.createTemporaryQueue();
JmsPoolQueueSender sender1 = (JmsPoolQueueSender) session.createSender(queue1);
JmsPoolQueueSender sender2 = (JmsPoolQueueSender) session.createSender(queue2);
if (useAnonymousProducers) {
assertSame(sender1.getMessageProducer(), sender2.getMessageProducer());
} else {
assertNotSame(sender1.getMessageProducer(), sender2.getMessageProducer());
}
connection.close();
}
示例2: testGetQueue
import javax.jms.QueueSession; //導入方法依賴的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) {}
}
示例3: testGetTopicSubscriber
import javax.jms.QueueSession; //導入方法依賴的package包/類
@Test
public void testGetTopicSubscriber() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createTemporaryQueue();
JmsPoolQueueSender sender = (JmsPoolQueueSender) session.createSender(queue);
assertNotNull(sender.getQueueSender());
assertTrue(sender.getQueueSender() instanceof MockJMSQueueSender);
sender.close();
try {
sender.getQueueSender();
fail("Cannot read state on closed sender");
} catch (IllegalStateException ise) {}
}
示例4: testSenderAndPublisherDest
import javax.jms.QueueSession; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testSenderAndPublisherDest() throws Exception {
JmsPoolXAConnectionFactory pcf = new JmsPoolXAConnectionFactory();
pcf.setConnectionFactory(new ActiveMQXAConnectionFactory(
"vm://test?broker.persistent=false&broker.useJmx=false"));
QueueConnection connection = pcf.createQueueConnection();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(session.createQueue("AA"));
assertNotNull(sender.getQueue().getQueueName());
connection.close();
TopicConnection topicConnection = pcf.createTopicConnection();
TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicPublisher topicPublisher = topicSession.createPublisher(topicSession.createTopic("AA"));
assertNotNull(topicPublisher.getTopic().getTopicName());
topicConnection.close();
pcf.stop();
}
示例5: invokeJMS
import javax.jms.QueueSession; //導入方法依賴的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!");
}
示例6: send
import javax.jms.QueueSession; //導入方法依賴的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();
}
示例7: acknowledge
import javax.jms.QueueSession; //導入方法依賴的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();
}
}
示例8: sendMessage
import javax.jms.QueueSession; //導入方法依賴的package包/類
/**
* Send a message to testInboundQueue queue
*
* @throws Exception
*/
private void sendMessage() throws Exception {
InitialContext initialContext = JmsClientHelper.getActiveMqInitialContext();
QueueConnectionFactory connectionFactory
= (QueueConnectionFactory) initialContext.lookup(JmsClientHelper.QUEUE_CONNECTION_FACTORY);
QueueConnection queueConnection = connectionFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
QueueSender sender = queueSession.createSender(queueSession.createQueue(QUEUE_NAME));
String message = "<?xml version='1.0' encoding='UTF-8'?>" +
" <ser:getQuote xmlns:ser=\"http://services.samples\" xmlns:xsd=\"http://services.samples/xsd\"> " +
" <ser:request>" +
" <xsd:symbol>IBM</xsd:symbol>" +
" </ser:request>" +
" </ser:getQuote>";
try {
TextMessage jmsMessage = queueSession.createTextMessage(message);
jmsMessage.setJMSType("incorrecttype");
sender.send(jmsMessage);
} finally {
queueConnection.close();
}
}
示例9: testCreateReceiverWithMessageSelector
import javax.jms.QueueSession; //導入方法依賴的package包/類
/**
* com.sun.ts.tests.jms.ee.all.queueconn.QueueConnTest line 171
*/
@Test
public void testCreateReceiverWithMessageSelector() throws Exception {
QueueConnection qc = null;
try {
qc = createQueueConnection();
QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueReceiver qreceiver = qs.createReceiver(queue1, "targetMessage = TRUE");
qc.start();
TextMessage m = qs.createTextMessage();
m.setText("one");
m.setBooleanProperty("targetMessage", false);
QueueSender qsender = qs.createSender(queue1);
qsender.send(m);
m.setText("two");
m.setBooleanProperty("targetMessage", true);
qsender.send(m);
TextMessage rm = (TextMessage) qreceiver.receive(1000);
ProxyAssertSupport.assertEquals("two", rm.getText());
} finally {
if (qc != null) {
qc.close();
}
Thread.sleep(2000);
removeAllMessages(queue1.getQueueName(), true);
checkEmpty(queue1);
}
}
示例10: createSender
import javax.jms.QueueSession; //導入方法依賴的package包/類
/**
* Create a queue sender
*
* @param queue The queue
* @return The queue sender
* @throws JMSException Thrown if an error occurs
*/
@Override
public QueueSender createSender(final Queue queue) throws JMSException {
lock();
try {
QueueSession session = getQueueSessionInternal();
if (ActiveMQRASession.trace) {
ActiveMQRALogger.LOGGER.trace("createSender " + session + " queue=" + queue);
}
QueueSender result = session.createSender(queue);
result = new ActiveMQRAQueueSender(result, this);
if (ActiveMQRASession.trace) {
ActiveMQRALogger.LOGGER.trace("createdSender " + session + " sender=" + result);
}
addProducer(result);
return result;
} finally {
unlock();
}
}
示例11: testCreateQueueSender
import javax.jms.QueueSession; //導入方法依賴的package包/類
@Test
public void testCreateQueueSender() throws Exception {
JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerAmqpConnectionURI());
QueueConnection connection = factory.createQueueConnection();
assertNotNull(connection);
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(session);
Queue queue = session.createQueue(name.getMethodName());
QueueSender sender = session.createSender(queue);
assertNotNull(sender);
QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
assertEquals(0, proxy.getQueueSize());
connection.close();
}
示例12: sendReply
import javax.jms.QueueSession; //導入方法依賴的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);
}
}
}
}
示例13: submitJob
import javax.jms.QueueSession; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void submitJob(AbstractFileManagementJob job) {
ServiceLocator locator = ServiceLocatorFactory.getLocator();
final QueueConnectionFactory factory = (QueueConnectionFactory) locator.lookup(DEFAULT_QUEUE_CONN_FACTORY);
final Queue queue = (Queue) locator.lookup(FileManagementMDB.QUEUE_JNDI_NAME);
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
try {
queueConnection = factory.createQueueConnection();
queueSession = queueConnection.createQueueSession(true, 0);
queueSender = queueSession.createSender(queue);
final ObjectMessage message = queueSession.createObjectMessage(job);
queueSender.send(message);
} catch (JMSException e) {
LOG.error("Couldn't submit job to JMS", e);
} finally {
close(queueSender);
close(queueSession);
close(queueConnection);
}
}
示例14: createSender
import javax.jms.QueueSession; //導入方法依賴的package包/類
public QueueSender createSender(Queue queue) throws JMSException {
lock();
try {
QueueSession session = getQueueSession();
if (trace)
log.trace("createSender " + session + " queue=" + queue);
QueueSender result = session.createSender(queue);
result = new JmsQueueSender(result, this);
if (trace)
log.trace("createdSender " + session + " sender=" + result);
addProducer(result);
return result;
} finally {
unlock();
}
}
示例15: testToString
import javax.jms.QueueSession; //導入方法依賴的package包/類
@Test
public void testToString() 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.toString());
}