use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivation in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testNonDurableSubscriptionDeleteAfterCrash.
// https://issues.jboss.org/browse/JBPAPP-8017
@Test
public void testNonDurableSubscriptionDeleteAfterCrash() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Topic");
spec.setDestination("mdbTopic");
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
ClientSession session = locator.createSessionFactory().createSession();
ClientProducer clientProducer = session.createProducer("mdbTopic");
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("1");
clientProducer.send(message);
latch.await(5, TimeUnit.SECONDS);
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "1");
ActiveMQActivation activation = lookupActivation(qResourceAdapter);
SimpleString tempQueueName = activation.getTopicTemporaryQueue();
QueueQuery query = session.queueQuery(tempQueueName);
assertTrue(query.isExists());
// this should be enough to simulate the crash
qResourceAdapter.getDefaultActiveMQConnectionFactory().close();
qResourceAdapter.stop();
query = session.queueQuery(tempQueueName);
assertFalse(query.isExists());
}
use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivation in project activemq-artemis by apache.
the class ActiveMQResourceAdapter method endpointActivation.
/**
* Endpoint activation
*
* @param endpointFactory The endpoint factory
* @param spec The activation spec
* @throws ResourceException Thrown if an error occurs
*/
@Override
public void endpointActivation(final MessageEndpointFactory endpointFactory, final ActivationSpec spec) throws ResourceException {
if (spec == null) {
throw ActiveMQRABundle.BUNDLE.noActivationSpec();
}
if (!configured.getAndSet(true)) {
try {
setup();
} catch (ActiveMQException e) {
throw new ResourceException("Unable to create activation", e);
}
}
if (logger.isTraceEnabled()) {
logger.trace("endpointActivation(" + endpointFactory + ", " + spec + ")");
}
ActiveMQActivation activation = new ActiveMQActivation(this, endpointFactory, (ActiveMQActivationSpec) spec);
activations.put(spec, activation);
activation.start();
}
Aggregations