use of javax.jms.JMSContext in project wildfly by wildfly.
the class ScopedInjectedJMSContextTestCase method transactionScoped.
/**
* Test that a transaction-scoped JMSContext is properly cleaned up after the transaction completion.
*/
@Test
public void transactionScoped() throws Exception {
String text = UUID.randomUUID().toString();
try (JMSContext context = factory.createContext()) {
context.createProducer().setDeliveryMode(NON_PERSISTENT).send(queueForTransactionScope, text);
assertTrue(transactedConsumer.receive(queueForTransactionScope, text));
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class InjectedJMSContextTestCase method sendAndReceiveWithContext.
@Test
public void sendAndReceiveWithContext() throws JMSException {
String text = UUID.randomUUID().toString();
try (JMSContext context = factory.createContext()) {
TemporaryQueue tempQueue = context.createTemporaryQueue();
context.createProducer().send(tempQueue, text);
assertMessageIsReceived(tempQueue, context, text, false);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class InjectedJMSContextTestCase method tearDown.
@After
public void tearDown() throws JMSException {
// drain the queue to remove any pending messages from it
try (JMSContext context = factory.createContext()) {
JMSConsumer consumer = context.createConsumer(queue);
Message m;
do {
m = consumer.receiveNoWait();
} while (m != null);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class MessagingBean method checkAnnotationBasedDefinitionsWithVaultedAttributes.
public void checkAnnotationBasedDefinitionsWithVaultedAttributes() {
assertNotNull(factory5);
// verify authentication using vaulted attributes works fine
JMSContext context = factory5.createContext();
assertNotNull(context);
context.close();
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class EJB2xMDB method onMessage.
@Override
public void onMessage(Message message) {
logger.trace("Received message " + message + " in MDB " + this.getClass().getName());
try {
if (message.getStringProperty("MessageFormat") != null)
logger.trace("MessageFormat property = " + message.getStringProperty("MessageFormat"));
Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
try {
logger.trace("mdbContext = " + mdbContext);
replyTo = (Destination) mdbContext.lookup("jms/replyQueue");
} catch (Throwable e) {
logger.warn(e);
}
} else {
logger.trace("Using replyTo from message JMSReplyTo: " + replyTo);
}
if (replyTo == null) {
throw new EJBException("no replyTo Destination");
}
final TextMessage tm = (TextMessage) message;
final String reply = tm.getText() + "processed by: " + hashCode();
try (JMSContext context = cf.createContext()) {
context.createProducer().setJMSCorrelationID(message.getJMSMessageID()).send(replyTo, reply);
}
} catch (Exception e) {
logger.error(e);
throw new EJBException(e);
}
}
Aggregations