本文整理汇总了Java中org.apache.activemq.command.ConsumerInfo.setNoLocal方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerInfo.setNoLocal方法的具体用法?Java ConsumerInfo.setNoLocal怎么用?Java ConsumerInfo.setNoLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.ConsumerInfo
的用法示例。
在下文中一共展示了ConsumerInfo.setNoLocal方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: AdvisoryConsumer
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public AdvisoryConsumer(ActiveMQConnection connection, ConsumerId consumerId) throws JMSException {
this.connection = connection;
info = new ConsumerInfo(consumerId);
info.setDestination(AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC);
info.setPrefetchSize(1000);
info.setNoLocal(true);
info.setDispatchAsync(true);
this.connection.addDispatcher(info.getConsumerId(), this);
this.connection.syncSendPacket(this.info);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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());
}
示例6: 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());
}
示例7: testConnectionCloseCascades
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testConnectionCloseCascades() throws Exception {
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo1);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setPrefetchSize(100);
consumerInfo1.setNoLocal(true);
connection1.request(consumerInfo1);
// Setup a second connection
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
connection2.send(producerInfo2);
// Send the messages
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
for (int i = 0; i < 4; i++) {
Message m1 = receiveMessage(connection1);
assertNotNull(m1);
connection1.send(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
}
// give the async ack a chance to perculate and validate all are currently consumed
Message msg = receiveMessage(connection1, MAX_NULL_WAIT);
assertNull("all messages were received " + msg, msg);
// Close the connection, this should in turn close the consumer.
connection1.request(closeConnectionInfo(connectionInfo1));
// Send another message, connection1 should not get the message.
connection2.request(createMessage(producerInfo2, destination, deliveryMode));
assertNull("no message received", receiveMessage(connection1, MAX_NULL_WAIT));
}
示例8: testSessionCloseCascades
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testSessionCloseCascades() throws Exception {
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo1);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setPrefetchSize(100);
consumerInfo1.setNoLocal(true);
connection1.request(consumerInfo1);
// Setup a second connection
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
connection2.send(producerInfo2);
// Send the messages
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
for (int i = 0; i < 4; i++) {
Message m1 = receiveMessage(connection1);
assertNotNull(m1);
connection1.send(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
}
// Close the session, this should in turn close the consumer.
connection1.request(closeSessionInfo(sessionInfo1));
// Send another message, connection1 should not get the message.
connection2.request(createMessage(producerInfo2, destination, deliveryMode));
Message msg = receiveMessage(connection1, MAX_NULL_WAIT);
assertNull("no message received from connection1 after session close", msg);
}
示例9: testConsumerClose
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testConsumerClose() throws Exception {
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo1);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setPrefetchSize(100);
consumerInfo1.setNoLocal(true);
connection1.request(consumerInfo1);
// Setup a second connection
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
connection2.send(producerInfo2);
// Send the messages
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
connection2.send(createMessage(producerInfo2, destination, deliveryMode));
for (int i = 0; i < 4; i++) {
Message m1 = receiveMessage(connection1);
assertNotNull(m1);
connection1.send(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
}
// give the async ack a chance to perculate and validate all are currently consumed
// use receive rather than poll as broker info is sent async and may still need to be dequeued
Message result = receiveMessage(connection1, MAX_NULL_WAIT);
assertNull("no more messages " + result, result);
// Close the consumer.
connection1.request(closeConsumerInfo(consumerInfo1));
// Send another message, connection1 should not get the message.
connection2.request(createMessage(producerInfo2, destination, deliveryMode));
result = receiveMessage(connection1, MAX_NULL_WAIT);
assertNull("no message received after close " + result, result);
}
示例10: testTopicNoLocal
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testTopicNoLocal() throws Exception {
ActiveMQDestination destination = new ActiveMQTopic("TEST");
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo1);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setRetroactive(true);
consumerInfo1.setPrefetchSize(100);
consumerInfo1.setNoLocal(true);
connection1.send(consumerInfo1);
// Setup a second connection
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
connection2.send(producerInfo2);
ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
consumerInfo2.setRetroactive(true);
consumerInfo2.setPrefetchSize(100);
consumerInfo2.setNoLocal(true);
connection2.send(consumerInfo2);
// Send the messages
connection1.send(createMessage(producerInfo1, destination, deliveryMode));
connection1.send(createMessage(producerInfo1, destination, deliveryMode));
connection1.send(createMessage(producerInfo1, destination, deliveryMode));
connection1.send(createMessage(producerInfo1, destination, deliveryMode));
// The 2nd connection should get the messages.
for (int i = 0; i < 4; i++) {
Message m1 = receiveMessage(connection2);
assertNotNull(m1);
}
// Send a message with the 2nd connection
Message message = createMessage(producerInfo2, destination, deliveryMode);
connection2.send(message);
// The first connection should not see the initial 4 local messages sent
// but should
// see the messages from connection 2.
Message m = receiveMessage(connection1);
assertNotNull(m);
assertEquals(message.getMessageId(), m.getMessageId());
assertNoMessagesLeft(connection1);
assertNoMessagesLeft(connection2);
}