use of javax.jms.JMSRuntimeException in project pentaho-kettle by pentaho.
the class JmsStreamSourceTest method handlesJmsRuntimeException.
@Test(timeout = 5000)
public void handlesJmsRuntimeException() {
when(consumer.receive(0)).thenThrow(new JMSRuntimeException("exception"));
source.open();
verify(delegate).getJmsContext();
verify(delegate).getDestination();
try {
source.flowable().firstElement().blockingGet(Collections.emptyList());
fail("Expected exception ");
} catch (Exception e) {
assertTrue(e instanceof JMSRuntimeException);
}
}
use of javax.jms.JMSRuntimeException in project qpid-broker-j by apache.
the class DeliveryDelayTest method testDeliveryDelayNotSupportedByQueueViaExchange_MessageRejected.
/**
* The client sends a messagge to a fanout exchange instance which is bound to a queue with
* holdsOnPublish turned off. The Broker must reject the message.
*/
@Test
public void testDeliveryDelayNotSupportedByQueueViaExchange_MessageRejected() throws Exception {
try (JMSContext context = getConnectionBuilder().buildConnectionFactory().createContext()) {
String testQueueName = BrokerAdmin.TEST_QUEUE_NAME;
String testExchangeName = "test_exch";
Destination consumeDest = createQueue(context, testQueueName, false);
Destination publishDest = createExchange(context, testExchangeName);
bindQueueToExchange(testExchangeName, testQueueName);
JMSConsumer consumer = context.createConsumer(consumeDest);
JMSProducer producer = context.createProducer();
producer.send(publishDest, "message without delivery delay");
Message message = consumer.receive(getReceiveTimeout());
assertNotNull("Message published without delivery delay not received", message);
producer.setDeliveryDelay(DELIVERY_DELAY);
try {
producer.send(publishDest, "message with delivery delay");
fail("Exception not thrown");
} catch (JMSRuntimeException e) {
assertTrue("Unexpected exception message: " + e.getMessage(), e.getMessage().contains("amqp:precondition-failed"));
}
}
}
use of javax.jms.JMSRuntimeException in project qpid-broker-j by apache.
the class DeliveryDelayTest method testDeliveryDelayNotSupportedByQueue_MessageRejected.
/**
* The target queue, which is addressed directly by the client, does not have
* holdsOnPublish turned on. The Broker must reject the message.
*/
@Test
public void testDeliveryDelayNotSupportedByQueue_MessageRejected() throws Exception {
try (JMSContext context = getConnectionBuilder().buildConnectionFactory().createContext()) {
Destination queue = createQueue(context, BrokerAdmin.TEST_QUEUE_NAME, false);
JMSProducer producer = context.createProducer().setDeliveryDelay(DELIVERY_DELAY);
try {
producer.send(queue, "message");
fail("Exception not thrown");
} catch (JMSRuntimeException e) {
assertTrue("Unexpected exception message: " + e.getMessage(), e.getMessage().contains("amqp:precondition-failed"));
}
}
}
use of javax.jms.JMSRuntimeException in project activemq-artemis by apache.
the class ActiveMQJMSProducer method getObjectProperty.
@Override
public Object getObjectProperty(String name) {
try {
SimpleString key = new SimpleString(name);
Object property = properties.getProperty(key);
if (stringPropertyNames.contains(key)) {
property = property.toString();
}
return property;
} catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
} catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
use of javax.jms.JMSRuntimeException in project activemq-artemis by apache.
the class ActiveMQConnection method createSessionInternal.
protected final ActiveMQSession createSessionInternal(final boolean isXA, final boolean transacted, int acknowledgeMode, final int type) throws JMSException {
if (transacted) {
acknowledgeMode = Session.SESSION_TRANSACTED;
}
try {
ClientSession session;
boolean isBlockOnAcknowledge = sessionFactory.getServerLocator().isBlockOnAcknowledge();
int ackBatchSize = sessionFactory.getServerLocator().getAckBatchSize();
if (acknowledgeMode == Session.SESSION_TRANSACTED) {
session = sessionFactory.createSession(username, password, isXA, false, false, sessionFactory.getServerLocator().isPreAcknowledge(), transactionBatchSize);
} else if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), 0);
} else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), dupsOKBatchSize);
} else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, false, sessionFactory.getServerLocator().isPreAcknowledge(), isBlockOnAcknowledge ? transactionBatchSize : ackBatchSize);
} else if (acknowledgeMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, false, false, isBlockOnAcknowledge ? transactionBatchSize : ackBatchSize);
} else if (acknowledgeMode == ActiveMQJMSConstants.PRE_ACKNOWLEDGE) {
session = sessionFactory.createSession(username, password, isXA, true, false, true, transactionBatchSize);
} else {
throw new JMSRuntimeException("Invalid ackmode: " + acknowledgeMode);
}
justCreated = false;
// Setting multiple times on different sessions doesn't matter since RemotingConnection
// maintains
// a set (no duplicates)
session.addFailureListener(listener);
session.addFailoverListener(failoverListener);
ActiveMQSession jbs = createAMQSession(isXA, transacted, acknowledgeMode, session, type);
sessions.add(jbs);
if (started) {
session.start();
}
this.addSessionMetaData(session);
return jbs;
} catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
Aggregations