use of javax.jms.JMSContext 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);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class ClusteredMessagingTestCase method createJMSContext.
protected static JMSContext createJMSContext(Context ctx) throws NamingException {
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
assertNotNull(cf);
JMSContext context = cf.createContext("guest", "guest");
return context;
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class ClusteredMessagingTestCase method sendMessage.
protected static void sendMessage(Context ctx, String destinationLookup, String text) 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")) {
context.createProducer().send(destination, text);
}
}
use of javax.jms.JMSContext in project Payara by payara.
the class InjectableJMSContext method toString.
@Override
public String toString() {
JMSContext rContext = null;
JMSContext tContext = null;
try {
boolean isInTransaction = isInTransaction();
if (isInTransaction) {
TransactedJMSContextManager manager = getTransactedManager();
tContext = manager.getContext(id);
if (tContext == null)
tContext = manager.getContext(ipId, id, metadata, getConnectionFactory(isInTransaction));
} else {
rContext = requestedManager.getContext(id);
if (rContext == null)
rContext = requestedManager.getContext(ipId, id, metadata, getConnectionFactory(isInTransaction));
}
} catch (ContextNotActiveException cnae) {
// if toString() is called in an env which doesn't have valid CDI request/transaction scope,
// then we don't call the CDI proxy for creating a new JMSContext bean.
}
StringBuffer sb = new StringBuffer();
sb.append("JMSContext Wrapper ").append(ipId).append(" with metadata [").append(metadata).append("]");
if (tContext != null)
sb.append(", around ").append(getTransactedManager().getType()).append(" [").append(tContext).append("]");
else if (rContext != null)
sb.append(", around ").append(requestedManager.getType()).append(" [").append(rContext).append("]");
else
sb.append(", there is neither a transaction or a valid request scope.");
return sb.toString();
}
use of javax.jms.JMSContext in project activemq-artemis by apache.
the class JMSContextTest method testCreateContextThrowsException.
@Test
public void testCreateContextThrowsException() throws Exception {
JMSContext jmsctx = qraConnectionFactory.createContext();
try {
jmsctx.createContext(JMSContext.AUTO_ACKNOWLEDGE);
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException e) {
// pass
} catch (Exception e) {
fail("wrong exception thrown: " + e);
}
}
Aggregations