use of javax.jms.JMSContext in project wildfly by wildfly.
the class CriticalAnalyzerTestCase method testCriticalAnalyzerDisabled.
/**
* Disable the critical analyzer.
* Use the byteman script to simulate a slow journal that would make the critical analyzer to activate.
* Check that there is nothing in the logs and that the broker is still running.
* @throws Exception
*/
@Test
public void testCriticalAnalyzerDisabled() throws Exception {
if (!container.isStarted(DEFAULT_FULL_JBOSSAS)) {
container.start(DEFAULT_FULL_JBOSSAS);
}
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
managementClient.getControllerClient().execute(Operations.createWriteAttributeOperation(jmsOperations.getServerAddress(), "critical-analyzer-enabled", ModelNode.FALSE));
jmsOperations.close();
managementClient.close();
container.stop(DEFAULT_FULL_JBOSSAS);
container.start(DEFAULT_FULL_JBOSSAS);
InitialContext remoteContext = createJNDIContext();
managementClient = createManagementClient();
ConnectionFactory cf = (ConnectionFactory) remoteContext.lookup("jms/RemoteConnectionFactory");
Queue queue = (Queue) remoteContext.lookup("queue/critical");
deployRules();
try (JMSContext context = cf.createContext("guest", "guest", JMSContext.AUTO_ACKNOWLEDGE)) {
JMSProducer producer = context.createProducer();
for (int i = 0; i < 20; i++) {
TextMessage message = context.createTextMessage(RandomStringUtils.randomAlphabetic(10));
producer.send(queue, message);
}
}
remoteContext.close();
assertTrue(isBrokerRunning());
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class AbstractMessagingHATestCase method receiveMessage.
protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException {
log.trace("Looking up for the RemoteConnectionFactory with " + ctx);
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
assertNotNull(cf);
log.trace("Looking up for the destination with " + ctx);
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, TimeoutUtil.adjust(5000));
assertNotNull(text);
assertEquals(expectedText, text);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class JMSSender method sendMessage.
@TransactionAttribute(NOT_SUPPORTED)
public void sendMessage(String payload) {
try (JMSContext context = connectionFactory.createContext()) {
JMSProducer producer = context.createProducer();
producer.send(queue, payload);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class InjectedJMSContextTestCase method sendWith_REQUIRED_transaction.
private void sendWith_REQUIRED_transaction(boolean rollback) throws JMSException {
String text = UUID.randomUUID().toString();
try (JMSContext context = factory.createContext()) {
TemporaryQueue tempQueue = context.createTemporaryQueue();
producerBean.sendToDestination(tempQueue, text, rollback);
assertMessageIsReceived(tempQueue, context, text, rollback);
}
}
use of javax.jms.JMSContext in project wildfly by wildfly.
the class InjectedJMSContextTestCase method sendAndReceiveFromMDB.
private void sendAndReceiveFromMDB(boolean rollback) throws JMSException {
String text = "sendAndReceiveFromMDB " + rollback;
try (JMSContext context = factory.createContext()) {
TemporaryQueue replyTo = context.createTemporaryQueue();
context.createProducer().setJMSReplyTo(replyTo).setProperty("rollback", rollback).send(queue, text);
assertMessageIsReceived(replyTo, context, text, rollback);
}
}
Aggregations