本文整理汇总了Java中org.apache.activemq.command.ActiveMQMessage.getDataStructure方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQMessage.getDataStructure方法的具体用法?Java ActiveMQMessage.getDataStructure怎么用?Java ActiveMQMessage.getDataStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.ActiveMQMessage
的用法示例。
在下文中一共展示了ActiveMQMessage.getDataStructure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void onMessage(Message message) {
if (message instanceof ActiveMQMessage) {
ActiveMQMessage activeMessage = (ActiveMQMessage)message;
Object command = activeMessage.getDataStructure();
int count = 0;
if (command instanceof ProducerInfo) {
count = producerCount.incrementAndGet();
count = extractProducerCountFromMessage(message, count);
fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count));
} else if (command instanceof RemoveInfo) {
RemoveInfo removeInfo = (RemoveInfo)command;
if (removeInfo.isProducerRemove()) {
count = producerCount.decrementAndGet();
count = extractProducerCountFromMessage(message, count);
fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count));
}
} else {
LOG.warn("Unknown command: " + command);
}
} else {
LOG.warn("Unknown message type: " + message + ". Message ignored");
}
}
示例2: onMessage
import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void onMessage(Message message) {
if (message instanceof ActiveMQMessage) {
ActiveMQMessage activeMessage = (ActiveMQMessage)message;
Object command = activeMessage.getDataStructure();
int count = 0;
if (command instanceof ConsumerInfo) {
count = consumerCount.incrementAndGet();
count = extractConsumerCountFromMessage(message, count);
fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo)command, count));
} else if (command instanceof RemoveInfo) {
RemoveInfo removeInfo = (RemoveInfo)command;
if (removeInfo.isConsumerRemove()) {
count = consumerCount.decrementAndGet();
count = extractConsumerCountFromMessage(message, count);
fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId)removeInfo.getObjectId(), count));
}
} else {
LOG.warn("Unknown command: " + command);
}
} else {
LOG.warn("Unknown message type: " + message + ". Message ignored");
}
}
示例3: onMessage
import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void onMessage(Message message) {
if (message instanceof ActiveMQMessage) {
ActiveMQMessage activeMessage = (ActiveMQMessage) message;
Object command = activeMessage.getDataStructure();
if (command instanceof DestinationInfo) {
DestinationInfo destinationInfo = (DestinationInfo) command;
DestinationEvent event = new DestinationEvent(this, destinationInfo);
fireDestinationEvent(event);
}
else {
LOG.warn("Unknown dataStructure: " + command);
}
}
else {
LOG.warn("Unknown message type: " + message + ". Message ignored");
}
}
示例4: testTempMessageConsumedAdvisory
import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void testTempMessageConsumedAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = s.createTemporaryQueue();
MessageConsumer consumer = s.createConsumer(queue);
Topic advisoryTopic = AdvisorySupport.getMessageConsumedAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);
BytesMessage m = s.createBytesMessage();
m.writeBytes(new byte[1024]);
producer.send(m);
String id = m.getJMSMessageID();
Message msg = consumer.receive(1000);
assertNotNull(msg);
msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
ActiveMQMessage message = (ActiveMQMessage) msg;
ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
String originalId = payload.getJMSMessageID();
assertEquals(originalId, id);
}
示例5: testMessageConsumedAdvisory
import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void testMessageConsumedAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
Topic advisoryTopic = AdvisorySupport.getMessageConsumedAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);
BytesMessage m = s.createBytesMessage();
m.writeBytes(new byte[1024]);
producer.send(m);
String id = m.getJMSMessageID();
Message msg = consumer.receive(1000);
assertNotNull(msg);
msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
ActiveMQMessage message = (ActiveMQMessage) msg;
ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
String originalId = payload.getJMSMessageID();
assertEquals(originalId, id);
}