use of javax.jms.Destination in project wildfly by wildfly.
the class AbstractMessagingHATestCase method receiveMessage.
protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException {
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
assertNotNull(cf);
Destination destination = (Destination) ctx.lookup(destinationLookup);
assertNotNull(destination);
try (JMSContext context = cf.createContext("guest", "guest")) {
JMSConsumer consumer = context.createConsumer(destination);
String text = consumer.receiveBody(String.class, 5000);
assertNotNull(text);
assertEquals(expectedText, text);
}
}
use of javax.jms.Destination in project wildfly by wildfly.
the class ActivationPropertyTimeoutMDB method onMessage.
@Override
public void onMessage(Message message) {
try {
log.tracef("onMessage received message: %s '%s'", message, ((TextMessage) message).getText());
// this should mean that second attempt for calling onMessage comes to play
if (checker.getRolledback() > 0) {
log.tracef("Discarding message '%s' as onMessage called for second time", message);
return;
}
final Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
throw new RuntimeException("ReplyTo info in message was not specified" + " and bean does not know where to reply to");
}
TxTestUtil.enlistTestXAResource(tm.getTransaction(), checker);
try (JMSContext context = factory.createContext()) {
context.createProducer().setJMSCorrelationID(message.getJMSMessageID()).send(replyTo, REPLY_PREFIX + ((TextMessage) message).getText());
}
// would timeout txn - this timeout waiting has to be greater than 1 s
// (see transactionTimeout activation config property)
TxTestUtil.waitForTimeout(tm);
} catch (Exception e) {
throw new RuntimeException("onMessage method execution failed", e);
}
}
use of javax.jms.Destination in project wildfly by wildfly.
the class AnnotationTimeoutMDB method onMessage.
@Override
public void onMessage(Message message) {
try {
log.tracef("onMessage received message: %s '%s'", message, ((TextMessage) message).getText());
final Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
throw new RuntimeException("ReplyTo info in message was not specified" + " and bean does not know where to reply to");
}
TxTestUtil.enlistTestXAResource(tm.getTransaction(), checker);
try (JMSContext context = factory.createContext()) {
context.createProducer().setJMSCorrelationID(message.getJMSMessageID()).send(replyTo, REPLY_PREFIX + ((TextMessage) message).getText());
}
// would timeout txn when TransactionTimeout be cared
TxTestUtil.waitForTimeout(tm);
} catch (Exception e) {
throw new RuntimeException("onMessage method execution failed", e);
}
}
use of javax.jms.Destination in project wildfly by wildfly.
the class NoTimeoutMDB method onMessage.
@Override
public void onMessage(Message message) {
try {
log.tracef("onMessage received message: %s '%s'", message, ((TextMessage) message).getText());
final Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
throw new RuntimeException("ReplyTo info in message was not specified" + " and bean does not know where to reply to");
}
TxTestUtil.enlistTestXAResource(tm.getTransaction(), checker);
TxTestUtil.addSynchronization(tm.getTransaction(), checker);
try (JMSContext context = factory.createContext()) {
context.createProducer().setJMSCorrelationID(message.getJMSMessageID()).send(replyTo, REPLY_PREFIX + ((TextMessage) message).getText());
}
} catch (Exception e) {
throw new RuntimeException("onMessage method execution failed", e);
}
}
use of javax.jms.Destination in project wildfly by wildfly.
the class ClusteredMessagingTestCase method receiveMessage.
protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException {
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
assertNotNull(cf);
Destination destination = (Destination) ctx.lookup(destinationLookup);
assertNotNull(destination);
try (JMSContext context = cf.createContext("guest", "guest")) {
JMSConsumer consumer = context.createConsumer(destination);
receiveMessage(consumer, expectedText);
}
}
Aggregations