本文整理汇总了Java中org.apache.activemq.command.ConsumerInfo.setSelector方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerInfo.setSelector方法的具体用法?Java ConsumerInfo.setSelector怎么用?Java ConsumerInfo.setSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.ConsumerInfo
的用法示例。
在下文中一共展示了ConsumerInfo.setSelector方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDemandSubscription
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
protected DemandSubscription createDemandSubscription(ConsumerInfo info) throws IOException {
if (addToAlreadyInterestedConsumers(info)) {
return null; // don't want this subscription added
}
//add our original id to ourselves
info.addNetworkConsumerId(info.getConsumerId());
if (info.isDurable()) {
// set the subscriber name to something reproducible
info.setSubscriptionName(getSubscriberName(info.getDestination()));
// and override the consumerId with something unique so that it won't
// be removed if the durable subscriber (at the other end) goes away
info.setConsumerId(new ConsumerId(localSessionInfo.getSessionId(),
consumerIdGenerator.getNextSequenceId()));
}
info.setSelector(null);
return doCreateDemandSubscription(info);
}
示例2: createDurableSubscriber
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public ObjectName createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception {
ConnectionContext context = new ConnectionContext();
context.setBroker(safeGetBroker());
context.setClientId(clientId);
ConsumerInfo info = new ConsumerInfo();
ConsumerId consumerId = new ConsumerId();
consumerId.setConnectionId(clientId);
consumerId.setSessionId(sessionIdCounter.incrementAndGet());
consumerId.setValue(0);
info.setConsumerId(consumerId);
info.setDestination(new ActiveMQTopic(topicName));
info.setSubscriptionName(subscriberName);
info.setSelector(selector);
Subscription subscription = safeGetBroker().addConsumer(context, info);
safeGetBroker().removeConsumer(context, info);
if (subscription != null) {
return subscription.getObjectName();
}
return null;
}
示例3: createConnectionConsumer
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages, boolean noLocal)
throws JMSException {
checkClosedOrFailed();
ensureConnectionInfoSent();
ConsumerId consumerId = createConsumerId();
ConsumerInfo consumerInfo = new ConsumerInfo(consumerId);
consumerInfo.setDestination(ActiveMQMessageTransformation.transformDestination(destination));
consumerInfo.setSelector(messageSelector);
consumerInfo.setPrefetchSize(maxMessages);
consumerInfo.setNoLocal(noLocal);
consumerInfo.setDispatchAsync(isDispatchAsync());
// Allows the options on the destination to configure the consumerInfo
if (consumerInfo.getDestination().getOptions() != null) {
Map<String, String> options = new HashMap<String, String>(consumerInfo.getDestination().getOptions());
IntrospectionSupport.setProperties(consumerInfo, options, "consumer.");
}
return new ActiveMQConnectionConsumer(this, sessionPool, consumerInfo);
}
示例4: testSendingSmallMessage
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testSendingSmallMessage() throws Exception {
ConsumerInfo expected = new ConsumerInfo();
expected.setSelector("Cheese");
expected.setExclusive(true);
expected.setExclusive(true);
expected.setPrefetchSize(3456);
try {
LOG.info("About to send: " + expected);
producer.oneway(expected);
Command received = assertCommandReceived();
assertTrue("Should have received a ConsumerInfo but was: " + received, received instanceof ConsumerInfo);
ConsumerInfo actual = (ConsumerInfo) received;
assertEquals("Selector", expected.getSelector(), actual.getSelector());
assertEquals("isExclusive", expected.isExclusive(), actual.isExclusive());
assertEquals("getPrefetchSize", expected.getPrefetchSize(), actual.getPrefetchSize());
} catch (Exception e) {
LOG.info("Caught: " + e);
e.printStackTrace();
fail("Failed to send to transport: " + e);
}
}
示例5: createDemandSubscription
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
protected DemandSubscription createDemandSubscription(ConsumerInfo info) throws IOException {
if (addToAlreadyInterestedConsumers(info)) {
return null; // don't want this subscription added
}
//add our original id to ourselves
info.addNetworkConsumerId(info.getConsumerId());
info.setSelector(null);
return doCreateDemandSubscription(info);
}
示例6: createInactiveConsumerInfo
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public ConsumerInfo createInactiveConsumerInfo(SubscriptionInfo info) {
ConsumerInfo rc = new ConsumerInfo();
rc.setSelector(info.getSelector());
rc.setSubscriptionName(info.getSubscriptionName());
rc.setDestination(info.getSubscribedDestination());
rc.setConsumerId(createConsumerId());
return rc;
}
示例7: setSelector
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public void setSelector(String selector) throws InvalidSelectorException {
ConsumerInfo copy = info.copy();
copy.setSelector(selector);
BooleanExpression newSelector = parseSelector(copy);
// its valid so lets actually update it now
info.setSelector(selector);
this.selectorExpression = newSelector;
}
示例8: testSelectorSkipsMessages
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testSelectorSkipsMessages() throws Exception {
// Start a producer and consumer
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
ProducerInfo producerInfo = createProducerInfo(sessionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
connection.send(producerInfo);
destination = createDestinationInfo(connection, connectionInfo, destinationType);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
consumerInfo.setSelector("JMSType='last'");
connection.send(consumerInfo);
Message message1 = createMessage(producerInfo, destination, deliveryMode);
message1.setType("first");
Message message2 = createMessage(producerInfo, destination, deliveryMode);
message2.setType("last");
connection.send(message1);
connection.send(message2);
// Use selector to skip first message.
Message m = receiveMessage(connection);
assertNotNull(m);
assertEquals(m.getMessageId(), message2.getMessageId());
connection.send(createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE));
connection.send(closeConsumerInfo(consumerInfo));
assertNoMessagesLeft(connection);
}
示例9: testRequestResponse
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testRequestResponse() throws Exception {
ConsumerInfo expected = new ConsumerInfo();
expected.setSelector("Edam");
expected.setResponseRequired(true);
LOG.info("About to send: " + expected);
Response response = (Response) producer.request(expected, 2000);
LOG.info("Received: " + response);
assertNotNull("Received a response", response);
assertTrue("Should not be an exception", !response.isException());
}
示例10: populateObject
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ConsumerInfo info = (ConsumerInfo) object;
info.setConsumerId(createConsumerId("ConsumerId:1"));
info.setBrowser(true);
info.setDestination(createActiveMQDestination("Destination:2"));
info.setPrefetchSize(1);
info.setMaximumPendingMessageLimit(2);
info.setDispatchAsync(false);
info.setSelector("Selector:3");
info.setSubscriptionName("SubcriptionName:4");
info.setNoLocal(true);
info.setExclusive(false);
info.setRetroactive(true);
info.setPriority((byte) 1);
{
BrokerId value[] = new BrokerId[2];
for (int i = 0; i < 2; i++) {
value[i] = createBrokerId("BrokerPath:5");
}
info.setBrokerPath(value);
}
info.setAdditionalPredicate(createBooleanExpression("AdditionalPredicate:6"));
info.setNetworkSubscription(false);
info.setOptimizedAcknowledge(true);
info.setNoRangeAcks(false);
}
示例11: populateObject
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ConsumerInfo info = (ConsumerInfo) object;
info.setConsumerId(createConsumerId("ConsumerId:1"));
info.setBrowser(true);
info.setDestination(createActiveMQDestination("Destination:2"));
info.setPrefetchSize(1);
info.setMaximumPendingMessageLimit(2);
info.setDispatchAsync(false);
info.setSelector("Selector:3");
info.setSubscriptionName("SubscriptionName:4");
info.setNoLocal(true);
info.setExclusive(false);
info.setRetroactive(true);
info.setPriority((byte) 1);
{
BrokerId value[] = new BrokerId[2];
for (int i = 0; i < 2; i++) {
value[i] = createBrokerId("BrokerPath:5");
}
info.setBrokerPath(value);
}
info.setAdditionalPredicate(createBooleanExpression("AdditionalPredicate:6"));
info.setNetworkSubscription(false);
info.setOptimizedAcknowledge(true);
info.setNoRangeAcks(false);
}
示例12: tightUnmarshal
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
* Un-marshal an object instance from the data input stream
*
* @param o the object to un-marshal
* @param dataIn the data input stream to build the object from
* @throws IOException
*/
public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs)
throws IOException {
super.tightUnmarshal(wireFormat, o, dataIn, bs);
ConsumerInfo info = (ConsumerInfo)o;
info.setConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat,
dataIn, bs));
info.setBrowser(bs.readBoolean());
info
.setDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(
wireFormat,
dataIn,
bs));
info.setPrefetchSize(dataIn.readInt());
info.setMaximumPendingMessageLimit(dataIn.readInt());
info.setDispatchAsync(bs.readBoolean());
info.setSelector(tightUnmarshalString(dataIn, bs));
info.setSubscriptionName(tightUnmarshalString(dataIn, bs));
info.setNoLocal(bs.readBoolean());
info.setExclusive(bs.readBoolean());
info.setRetroactive(bs.readBoolean());
info.setPriority(dataIn.readByte());
if (bs.readBoolean()) {
short size = dataIn.readShort();
org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
for (int i = 0; i < size; i++) {
value[i] = (org.apache.activemq.command.BrokerId)tightUnmarsalNestedObject(wireFormat,
dataIn, bs);
}
info.setBrokerPath(value);
} else {
info.setBrokerPath(null);
}
info
.setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)tightUnmarsalNestedObject(
wireFormat,
dataIn,
bs));
info.setNetworkSubscription(bs.readBoolean());
info.setOptimizedAcknowledge(bs.readBoolean());
info.setNoRangeAcks(bs.readBoolean());
}
示例13: looseUnmarshal
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
* Un-marshal an object instance from the data input stream
*
* @param o the object to un-marshal
* @param dataIn the data input stream to build the object from
* @throws IOException
*/
public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
super.looseUnmarshal(wireFormat, o, dataIn);
ConsumerInfo info = (ConsumerInfo)o;
info.setConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat,
dataIn));
info.setBrowser(dataIn.readBoolean());
info
.setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(
wireFormat,
dataIn));
info.setPrefetchSize(dataIn.readInt());
info.setMaximumPendingMessageLimit(dataIn.readInt());
info.setDispatchAsync(dataIn.readBoolean());
info.setSelector(looseUnmarshalString(dataIn));
info.setSubscriptionName(looseUnmarshalString(dataIn));
info.setNoLocal(dataIn.readBoolean());
info.setExclusive(dataIn.readBoolean());
info.setRetroactive(dataIn.readBoolean());
info.setPriority(dataIn.readByte());
if (dataIn.readBoolean()) {
short size = dataIn.readShort();
org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
for (int i = 0; i < size; i++) {
value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
}
info.setBrokerPath(value);
} else {
info.setBrokerPath(null);
}
info
.setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)looseUnmarsalNestedObject(
wireFormat,
dataIn));
info.setNetworkSubscription(dataIn.readBoolean());
info.setOptimizedAcknowledge(dataIn.readBoolean());
info.setNoRangeAcks(dataIn.readBoolean());
}