use of org.apache.activemq.command.ConsumerControl in project activemq-artemis by apache.
the class ConsumerControlTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ConsumerControl info = (ConsumerControl) object;
info.setClose(true);
info.setConsumerId(createConsumerId("ConsumerId:1"));
info.setPrefetch(1);
info.setFlush(false);
info.setStart(true);
info.setStop(false);
}
use of org.apache.activemq.command.ConsumerControl in project activemq-artemis by apache.
the class ConsumerControlTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ConsumerControl info = (ConsumerControl) object;
info.setClose(true);
info.setConsumerId(createConsumerId("ConsumerId:1"));
info.setPrefetch(1);
info.setFlush(false);
info.setStart(true);
info.setStop(false);
}
use of org.apache.activemq.command.ConsumerControl in project activemq-artemis by apache.
the class ConsumerControlTest method createObject.
@Override
public Object createObject() throws Exception {
ConsumerControl info = new ConsumerControl();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ConsumerControl in project activemq-artemis by apache.
the class ZeroPrefetchConsumerTest method testBrokerZeroPrefetchConfigWithConsumerControl.
// https://issues.apache.org/jira/browse/AMQ-4234
// https://issues.apache.org/jira/browse/AMQ-4235
public void testBrokerZeroPrefetchConfigWithConsumerControl() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(brokerZeroQueue);
assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());
// verify sub view broker
// I comment out this because it checks broker internal
// which doesn't apply to artemis broker.
// Subscription sub = broker.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(brokerZeroQueue)).getConsumers().get(0);
// assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());
// manipulate Prefetch (like failover and stomp)
ConsumerControl consumerControl = new ConsumerControl();
consumerControl.setConsumerId(consumer.info.getConsumerId());
consumerControl.setDestination(ActiveMQDestination.transform(brokerZeroQueue));
// default for a q
consumerControl.setPrefetch(1000);
Object reply = ((ActiveMQConnection) connection).getTransport().request(consumerControl);
assertTrue("good request", !(reply instanceof ExceptionResponse));
assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());
}
use of org.apache.activemq.command.ConsumerControl in project activemq-artemis by apache.
the class AMQConsumer method init.
public void init(SlowConsumerDetectionListener slowConsumerDetectionListener, long nativeId) throws Exception {
SimpleString selector = info.getSelector() == null ? null : new SimpleString(info.getSelector());
boolean preAck = false;
if (info.isNoLocal()) {
if (!AdvisorySupport.isAdvisoryTopic(openwireDestination)) {
// tell the connection to add the property
this.session.getConnection().setNoLocal(true);
} else {
preAck = true;
}
String id = info.getClientId() != null ? info.getClientId() : this.getId().getConnectionId();
String noLocalSelector = MessageUtil.CONNECTION_ID_PROPERTY_NAME.toString() + "<>'" + id + "'";
if (selector == null) {
selector = new SimpleString(noLocalSelector);
} else {
selector = new SimpleString(info.getSelector() + " AND " + noLocalSelector);
}
}
SimpleString destinationName = new SimpleString(session.convertWildcard(openwireDestination.getPhysicalName()));
if (openwireDestination.isTopic()) {
SimpleString queueName = createTopicSubscription(info.isDurable(), info.getClientId(), destinationName.toString(), info.getSubscriptionName(), selector, destinationName);
serverConsumer = session.getCoreSession().createConsumer(nativeId, queueName, null, info.isBrowser(), false, -1);
serverConsumer.setlowConsumerDetection(slowConsumerDetectionListener);
// only advisory topic consumers need this.
((ServerConsumerImpl) serverConsumer).setPreAcknowledge(preAck);
} else {
try {
session.getCoreServer().createQueue(destinationName, RoutingType.ANYCAST, destinationName, null, true, false);
} catch (ActiveMQQueueExistsException e) {
// ignore
}
serverConsumer = session.getCoreSession().createConsumer(nativeId, destinationName, selector, info.isBrowser(), false, -1);
serverConsumer.setlowConsumerDetection(slowConsumerDetectionListener);
AddressSettings addrSettings = session.getCoreServer().getAddressSettingsRepository().getMatch(destinationName.toString());
if (addrSettings != null) {
// see PolicyEntry
if (info.getPrefetchSize() != 0 && addrSettings.getQueuePrefetch() == 0) {
// sends back a ConsumerControl
ConsumerControl cc = new ConsumerControl();
cc.setConsumerId(info.getConsumerId());
cc.setPrefetch(0);
session.getConnection().dispatch(cc);
}
}
}
serverConsumer.setProtocolData(this);
}
Aggregations