use of javax.jms.MessageProducer in project tomee by apache.
the class EncCmpBean method testJmsConnection.
private void testJmsConnection(final Connection connection) throws JMSException {
final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
final Topic topic = session.createTopic("test");
final MessageProducer producer = session.createProducer(topic);
producer.send(session.createMessage());
producer.close();
session.close();
connection.close();
}
use of javax.jms.MessageProducer in project tomee by apache.
the class AnnotatedFieldInjectionMdbBean method testJmsConnection.
private void testJmsConnection(final javax.jms.Connection connection) throws JMSException {
final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
final Topic topic = session.createTopic("test");
final MessageProducer producer = session.createProducer(topic);
producer.send(session.createMessage());
producer.close();
session.close();
connection.close();
}
use of javax.jms.MessageProducer in project tomee by apache.
the class ChatBean method respond.
private void respond(String text) throws JMSException {
Connection connection = null;
Session session = null;
try {
connection = connectionFactory.createConnection();
connection.start();
// Create a Session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create a MessageProducer from the Session to the Topic or Queue
MessageProducer producer = session.createProducer(answerQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a message
TextMessage message = session.createTextMessage(text);
// Tell the producer to send the message
producer.send(message);
} finally {
// Clean up
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
use of javax.jms.MessageProducer in project tomee by apache.
the class ChatBeanTest method test.
public void test() throws Exception {
EJBContainer.createEJBContainer().getContext().bind("inject", this);
final Connection connection = connectionFactory.createConnection();
connection.start();
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final MessageProducer questions = session.createProducer(questionQueue);
final MessageConsumer answers = session.createConsumer(answerQueue);
sendText("Hello World!", questions, session);
assertEquals("Hello, Test Case!", receiveText(answers));
sendText("How are you?", questions, session);
assertEquals("I'm doing well.", receiveText(answers));
sendText("Still spinning?", questions, session);
assertEquals("Once every day, as usual.", receiveText(answers));
}
use of javax.jms.MessageProducer in project tomee by apache.
the class ContextLookupStatelessBean method testJmsConnection.
private void testJmsConnection(final Connection connection) throws JMSException {
final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
final Topic topic = session.createTopic("test");
final MessageProducer producer = session.createProducer(topic);
producer.send(session.createMessage());
producer.close();
session.close();
connection.close();
}
Aggregations