本文整理汇总了Java中org.apache.activemq.store.TopicMessageStore类的典型用法代码示例。如果您正苦于以下问题:Java TopicMessageStore类的具体用法?Java TopicMessageStore怎么用?Java TopicMessageStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopicMessageStore类属于org.apache.activemq.store包,在下文中一共展示了TopicMessageStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTopicWithStoreNoSubscriptions
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
@Test
public void testTopicWithStoreNoSubscriptions() throws Exception {
String topicName = "test.topic";
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setText("test");
message.setDestination(new ActiveMQTopic(topicName));
message.setMessageId(new MessageId(id.generateId() + ":1", 0));
TopicMessageStore ms = adapter.createTopicMessageStore(new ActiveMQTopic(topicName));
ms.addMessage(context, message);
OpenWireCoreMessageTypeConverter c = new OpenWireCoreMessageTypeConverter(store);
MessageType messageType = c.convert(message);
assertEquals(XmlDataConstants.TEXT_TYPE_PRETTY, messageType.getType());
assertTrue(messageType.getQueues().getQueue().isEmpty());
}
示例2: testTopicWithStoreOneSub
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
@Test
public void testTopicWithStoreOneSub() throws Exception {
String topicName = "test.topic";
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setText("test");
message.setDestination(new ActiveMQTopic(topicName));
message.setMessageId(new MessageId(id.generateId() + ":1", 0));
TopicMessageStore ms = adapter.createTopicMessageStore(new ActiveMQTopic(topicName));
ms.addSubscription(new SubscriptionInfo("clientId", "subName"), false);
ms.addMessage(context, message);
OpenWireCoreMessageTypeConverter c = new OpenWireCoreMessageTypeConverter(store);
MessageType messageType = c.convert(message);
assertEquals(XmlDataConstants.TEXT_TYPE_PRETTY, messageType.getType());
assertEquals(ActiveMQDestination.createQueueNameForDurableSubscription(true, "clientId", "subName"),
messageType.getQueues().getQueue().get(0).getName());
}
示例3: acknowledge
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
public void acknowledge(final TopicMessageStore destination, final String clientId, final String subscriptionName,
final MessageId messageId, final MessageAck ack) throws IOException {
if (doingRecover) {
return;
}
if (ack.isInTransaction()) {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand() {
public MessageAck getMessageAck() {
return ack;
}
public void run(ConnectionContext ctx) throws IOException {
destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack);
}
@Override
public MessageStore getMessageStore() {
return destination;
}
});
} else {
destination.acknowledge(null, clientId, subscriptionName, messageId, ack);
}
}
示例4: acknowledge
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
final void acknowledge(ConnectionContext context, final TopicMessageStore destination, final String clientId, final String subscriptionName,
final MessageId messageId, final MessageAck ack) throws IOException {
if (ack.isInTransaction()) {
if (ack.getTransactionId().isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions()== false) {
destination.acknowledge(context, clientId, subscriptionName, messageId, ack);
} else {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand(context) {
public MessageAck getMessageAck() {
return ack;
}
public Future<Object> run(ConnectionContext ctx) throws IOException {
destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack);
return AbstractMessageStore.FUTURE;
}
});
}
} else {
destination.acknowledge(context, clientId, subscriptionName, messageId, ack);
}
}
示例5: testExportTopicsPatternEmpty
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
@Test
public void testExportTopicsPatternEmpty() throws Exception {
File kahaDbDir = storeFolder.newFolder();
ActiveMQTopic topic = new ActiveMQTopic("test.topic");
PersistenceAdapter adapter = getPersistenceAdapter(kahaDbDir);
adapter.start();
TopicMessageStore messageStore = adapter.createTopicMessageStore(topic);
messageStore.start();
SubscriptionInfo sub1 = new SubscriptionInfo("clientId1", "sub1");
sub1.setDestination(topic);
messageStore.addSubscription(sub1, false);
IdGenerator id = new IdGenerator();
ConnectionContext context = new ConnectionContext();
for (int i = 0; i < 5; i++) {
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setText("Test");
message.setProperty("MyStringProperty", "abc");
message.setProperty("MyIntegerProperty", 1);
message.setDestination(topic);
message.setMessageId(new MessageId(id.generateId() + ":1", i));
messageStore.addMessage(context, message);
}
adapter.stop();
//should be empty as no messages match empty.>
File xmlFile = new File(storeFolder.getRoot().getAbsoluteFile(), "outputXml.xml");
exportStore(ExportConfigurationBuilder.newBuilder()
.setTopicPattern("empty.>")
.setSource(kahaDbDir)
.setTarget(xmlFile));
validate(xmlFile, 0);
}
示例6: getSubscriberMessages
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
protected List<Message> getSubscriberMessages(SubscriptionView view) {
// TODO It is very dangerous operation for big backlogs
if (!(destinationFactory instanceof DestinationFactoryImpl)) {
throw new RuntimeException("unsupported by " + destinationFactory);
}
PersistenceAdapter adapter = ((DestinationFactoryImpl)destinationFactory).getPersistenceAdapter();
final List<Message> result = new ArrayList<Message>();
try {
ActiveMQTopic topic = new ActiveMQTopic(view.getDestinationName());
TopicMessageStore store = adapter.createTopicMessageStore(topic);
store.recover(new MessageRecoveryListener() {
@Override
public boolean recoverMessage(Message message) throws Exception {
result.add(message);
return true;
}
@Override
public boolean recoverMessageReference(MessageId messageReference) throws Exception {
throw new RuntimeException("Should not be called.");
}
@Override
public boolean hasSpace() {
return true;
}
@Override
public boolean isDuplicate(MessageId id) {
return false;
}
});
} catch (Throwable e) {
LOG.error("Failed to browse messages for Subscription {}", view, e);
}
return result;
}
示例7: Topic
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
public Topic(BrokerService brokerService, ActiveMQDestination destination, TopicMessageStore store,
DestinationStatistics parentStats, TaskRunnerFactory taskFactory) throws Exception {
super(brokerService, store, destination, parentStats);
this.topicStore = store;
// set default subscription recovery policy
if (AdvisorySupport.isMasterBrokerAdvisoryTopic(destination)) {
subscriptionRecoveryPolicy = new LastImageSubscriptionRecoveryPolicy();
setAlwaysRetroactive(true);
} else {
subscriptionRecoveryPolicy = new NoSubscriptionRecoveryPolicy();
}
this.taskRunner = taskFactory.createTaskRunner(this, "Topic " + destination.getPhysicalName());
}
示例8: TempTopic
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
/**
* @param brokerService
* @param destination
* @param store
* @param parentStats
* @param taskFactory
* @throws Exception
*/
public TempTopic(BrokerService brokerService,
ActiveMQDestination destination, TopicMessageStore store,
DestinationStatistics parentStats, TaskRunnerFactory taskFactory)
throws Exception {
super(brokerService, destination, store, parentStats, taskFactory);
this.tempDest = (ActiveMQTempDestination) destination;
}
示例9: TopicStorePrefetch
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
/**
* @param topic
* @param clientId
* @param subscriberName
*/
public TopicStorePrefetch(Subscription subscription,Topic topic, String clientId, String subscriberName) {
super(topic);
this.subscription=subscription;
this.store = (TopicMessageStore)topic.getMessageStore();
this.clientId = clientId;
this.subscriberName = subscriberName;
this.maxProducersToAudit=32;
this.maxAuditDepth=10000;
resetSize();
}
示例10: add
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
@Override
public void add(ConnectionContext context, Destination destination) throws Exception {
if (!destinations.contains(destination)) {
super.add(context, destination);
}
// do it just once per destination
if (durableDestinations.containsKey(destination.getActiveMQDestination())) {
return;
}
durableDestinations.put(destination.getActiveMQDestination(), destination);
if (active.get() || keepDurableSubsActive) {
Topic topic = (Topic) destination;
topic.activate(context, this);
if (pending.isEmpty(topic)) {
topic.recoverRetroactiveMessages(context, this);
}
this.enqueueCounter += pending.size();
} else if (destination.getMessageStore() != null) {
TopicMessageStore store = (TopicMessageStore) destination.getMessageStore();
try {
this.enqueueCounter += store.getMessageCount(subscriptionKey.getClientId(), subscriptionKey.getSubscriptionName());
} catch (IOException e) {
JMSException jmsEx = new JMSException("Failed to retrieve enqueueCount from store " + e);
jmsEx.setLinkedException(e);
throw jmsEx;
}
}
dispatchPending();
}
示例11: createTopicMessageStore
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException {
TopicMessageStore rc = topics.get(destination);
if (rc == null) {
rc = new MemoryTopicMessageStore(destination);
if (transactionStore != null) {
rc = transactionStore.proxy(rc);
}
topics.put(destination, rc);
}
return rc;
}
示例12: createTopicMessageStore
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
public TopicMessageStore createTopicMessageStore(ActiveMQTopic destinationName) throws IOException {
JournalTopicMessageStore store = topics.get(destinationName);
if (store == null) {
TopicMessageStore checkpointStore = longTermPersistence.createTopicMessageStore(destinationName);
store = new JournalTopicMessageStore(this, checkpointStore, destinationName);
topics.put(destinationName, store);
}
return store;
}
示例13: createTopicMessageStore
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
@Override
public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException {
TopicMessageStore rc = new JDBCTopicMessageStore(this, getAdapter(), wireFormat, destination, audit);
if (transactionStore != null) {
rc = transactionStore.proxy(rc);
}
return rc;
}
示例14: JournalTopicMessageStore
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
public JournalTopicMessageStore(JournalPersistenceAdapter adapter, TopicMessageStore checkpointStore,
ActiveMQTopic destinationName) {
super(adapter, checkpointStore, destinationName);
this.longTermStore = checkpointStore;
}
示例15: getLongTermTopicMessageStore
import org.apache.activemq.store.TopicMessageStore; //导入依赖的package包/类
/**
* @return Returns the longTermStore.
*/
public TopicMessageStore getLongTermTopicMessageStore() {
return longTermStore;
}