use of org.apache.activemq.advisory.ConsumerEventSource in project pinpoint by naver.
the class MessageConsumerBuilder method build.
public MessageConsumer build() throws Exception {
MessageConsumer consumer = null;
if (waitTillStarted) {
ConsumerEventSource consumerEventSource = new ConsumerEventSource(session.getConnection(), destination);
final CountDownLatch latch = new CountDownLatch(1);
consumerEventSource.setConsumerListener(new ConsumerListener() {
@Override
public void onConsumerEvent(ConsumerEvent event) {
latch.countDown();
}
});
try {
consumerEventSource.start();
consumer = this.session.createConsumer(this.destination);
if (!latch.await(5L, TimeUnit.SECONDS)) {
throw new TimeoutException("Timed out waiting for MessageConsumer start event.");
}
} finally {
consumerEventSource.stop();
}
} else {
consumer = this.session.createConsumer(this.destination);
}
if (this.messageListener != null) {
consumer.setMessageListener(this.messageListener);
}
return consumer;
}
use of org.apache.activemq.advisory.ConsumerEventSource in project cxf by apache.
the class JmsPublisher method start.
@Override
protected void start() throws PublisherRegistrationFailedFault {
if (demand) {
try {
producers = new HashMap<>();
advisories = new ArrayList<>();
for (TopicExpressionType topic : this.topic) {
ConsumerEventSource advisory = new ConsumerEventSource(connection, topicConverter.toActiveMQTopic(topic));
advisory.setConsumerListener(this);
advisory.start();
advisories.add(advisory);
}
} catch (Exception e) {
PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
throw new PublisherRegistrationFailedFault("Error starting demand-based publisher", fault, e);
}
}
}
Aggregations