• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ActiveMQMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.activemq.command.ActiveMQMessage的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQMessage类的具体用法?Java ActiveMQMessage怎么用?Java ActiveMQMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ActiveMQMessage类属于org.apache.activemq.command包,在下文中一共展示了ActiveMQMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testActiveMQOriginalDestination

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Test
public void testActiveMQOriginalDestination() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);

    template.sendBody("activemq:queue:foo", "Hello World");

    assertMockEndpointsSatisfied();

    // consume from bar
    Exchange out = consumer.receive("activemq:queue:bar", 5000);
    assertNotNull(out);

    // and we should have foo as the original destination
    JmsMessage msg = out.getIn(JmsMessage.class);
    Message jms = msg.getJmsMessage();
    ActiveMQMessage amq = assertIsInstanceOf(ActiveMQMessage.class, jms);
    ActiveMQDestination original = amq.getOriginalDestination();
    assertNotNull(original);
    assertEquals("foo", original.getPhysicalName());
    assertEquals("Queue", original.getDestinationTypeAsString());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:ActiveMQOriginalDestinationTest.java


示例2: send

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
/**
 * @param msg
 * @throws JMSException
 */
private void send(ActiveMQMessage msg, boolean eosMessage) throws JMSException {
    if (properties != null && (messageSequence == 0 || !addPropertiesOnFirstMsgOnly)) {
        for (Iterator<String> iter = properties.keySet().iterator(); iter.hasNext();) {
            String key = iter.next();
            Object value = properties.get(key);
            msg.setObjectProperty(key, value);
        }
    }
    msg.setType("org.apache.activemq.Stream");
    msg.setGroupID(info.getProducerId().toString());
    if (eosMessage) {
        msg.setGroupSequence(-1);
    } else {
        msg.setGroupSequence((int) messageSequence);
    }
    MessageId id = new MessageId(info.getProducerId(), messageSequence++);
    connection.send(info.getDestination(), msg, id, deliveryMode, priority, timeToLive, !eosMessage && !isAlwaysSyncSend());
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:23,代码来源:ActiveMQOutputStream.java


示例3: processInOnly

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
protected boolean processInOnly(final Exchange exchange, final AsyncCallback callback) {
    try {
        ActiveMQMessage message = getMessage(exchange);
        if (message != null) {
            message.setDestination(brokerEndpoint.getDestination());
            //if the ProducerBrokerExchange is null the broker will create it
            ProducerBrokerExchange producerBrokerExchange = (ProducerBrokerExchange) exchange.getProperty(BrokerEndpoint.PRODUCER_BROKER_EXCHANGE);

            brokerEndpoint.inject(producerBrokerExchange, message);


        }
    } catch (Exception e) {
        exchange.setException(e);
    }
    callback.done(true);
    return true;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:BrokerProducer.java


示例4: transformToMap

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
/**
 * Transform an ActiveMQBytesMessage to a Map
 * 
 * @param msg - bytes message to transform
 * @return map object
 * @throws JMSException
 */
protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException {
    Properties props = new Properties();

    props.putAll(transformToMap((ActiveMQMessage)msg));

    long bodyLength = msg.getBodyLength();
    byte[] msgBody;
    int i = 0;
    // Create separate bytes messages
    for (i = 0; i < (bodyLength / Integer.MAX_VALUE); i++) {
        msgBody = new byte[Integer.MAX_VALUE];
        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody));
    }
    msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)];
    props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody));

    return props;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:MapTransformFilter.java


示例5: 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");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:ProducerEventSource.java


示例6: 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");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:ConsumerEventSource.java


示例7: messageExpired

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
    super.messageExpired(context, messageReference, subscription);
    try {
        if(!messageReference.isAdvisory()) {
            ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(messageReference.getMessage().getDestination());
            Message payload = messageReference.getMessage().copy();
            payload.clearBody();
            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
            advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
            fireAdvisory(context, topic, payload, null, advisoryMessage);
        }
    } catch (Exception e) {
        handleFireFailure("expired", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:17,代码来源:AdvisoryBroker.java


示例8: messageDiscarded

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) {
    super.messageDiscarded(context, sub, messageReference);
    try {
        if (!messageReference.isAdvisory()) {
            ActiveMQTopic topic = AdvisorySupport.getMessageDiscardedAdvisoryTopic(messageReference.getMessage().getDestination());
            Message payload = messageReference.getMessage().copy();
            payload.clearBody();
            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
            if (sub instanceof TopicSubscription) {
                advisoryMessage.setIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT, ((TopicSubscription)sub).discarded());
            }
            advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, sub.getConsumerInfo().getConsumerId().toString());
            fireAdvisory(context, topic, payload, null, advisoryMessage);
        }
    } catch (Exception e) {
        handleFireFailure("discarded", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:20,代码来源:AdvisoryBroker.java


示例9: isFull

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void isFull(ConnectionContext context, Destination destination, Usage usage) {
    super.isFull(context, destination, usage);
    if (AdvisorySupport.isAdvisoryTopic(destination.getActiveMQDestination()) == false) {
        try {

            ActiveMQTopic topic = AdvisorySupport.getFullAdvisoryTopic(destination.getActiveMQDestination());
            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
            advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_USAGE_NAME, usage.getName());
            fireAdvisory(context, topic, null, null, advisoryMessage);

        } catch (Exception e) {
            handleFireFailure("is full", e);
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:17,代码来源:AdvisoryBroker.java


示例10: networkBridgeStarted

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void networkBridgeStarted(BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp) {
    try {
     if (brokerInfo != null) {
         ActiveMQMessage advisoryMessage = new ActiveMQMessage();
         advisoryMessage.setBooleanProperty("started", true);
         advisoryMessage.setBooleanProperty("createdByDuplex", createdByDuplex);
         advisoryMessage.setStringProperty("remoteIp", remoteIp);
         networkBridges.putIfAbsent(brokerInfo, advisoryMessage);

         ActiveMQTopic topic = AdvisorySupport.getNetworkBridgeAdvisoryTopic();

         ConnectionContext context = new ConnectionContext();
         context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
         context.setBroker(getBrokerService().getBroker());
         fireAdvisory(context, topic, brokerInfo, null, advisoryMessage);
     }
    } catch (Exception e) {
        handleFireFailure("network bridge started", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:22,代码来源:AdvisoryBroker.java


示例11: networkBridgeStopped

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void networkBridgeStopped(BrokerInfo brokerInfo) {
    try {
     if (brokerInfo != null) {
         ActiveMQMessage advisoryMessage = new ActiveMQMessage();
         advisoryMessage.setBooleanProperty("started", false);
         networkBridges.remove(brokerInfo);

         ActiveMQTopic topic = AdvisorySupport.getNetworkBridgeAdvisoryTopic();

         ConnectionContext context = new ConnectionContext();
         context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
         context.setBroker(getBrokerService().getBroker());
         fireAdvisory(context, topic, brokerInfo, null, advisoryMessage);
     }
    } catch (Exception e) {
        handleFireFailure("network bridge stopped", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:20,代码来源:AdvisoryBroker.java


示例12: createMessageDispatch

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
public MessageDispatch createMessageDispatch(MessageReference reference,
                                                    ICoreMessage message,
                                                    AMQConsumer consumer) throws IOException, JMSException {
   ActiveMQMessage amqMessage = toAMQMessage(reference, message, consumer.getOpenwireDestination());

   //we can use core message id for sequenceId
   amqMessage.getMessageId().setBrokerSequenceId(message.getMessageID());
   MessageDispatch md = new MessageDispatch();
   md.setConsumerId(consumer.getId());
   md.setRedeliveryCounter(reference.getDeliveryCount() - 1);
   md.setDeliverySequenceId(amqMessage.getMessageId().getBrokerSequenceId());
   md.setMessage(amqMessage);
   ActiveMQDestination destination = amqMessage.getDestination();
   md.setDestination(destination);

   return md;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:OpenWireMessageConverter.java


示例13: onTransportError

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
public void onTransportError() {
    if (connect != null) {
        if (connected.get() && connect.willTopic() != null && connect.willMessage() != null) {
            try {
                PUBLISH publish = new PUBLISH();
                publish.topicName(connect.willTopic());
                publish.qos(connect.willQos());
                publish.payload(connect.willMessage());
                ActiveMQMessage message = convertMessage(publish);
                message.setProducerId(producerId);
                message.onSend();
                sendToActiveMQ(message, null);
            } catch (Exception e) {
                LOG.warn("Failed to publish Will Message " + connect.willMessage());
            }
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:MQTTProtocolConverter.java


示例14: testSendReceive

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Test
public void testSendReceive() throws Exception {
   // Send a message to the broker.
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   ActiveMQDestination destination = createDestination(session, destinationType);
   System.out.println("destionation: " + destination);
   MessageProducer producer = session.createProducer(destination);
   producer.setDeliveryMode(this.deliveryMode);
   MessageConsumer consumer = session.createConsumer(destination);
   ActiveMQMessage message = new ActiveMQMessage();
   producer.send(message);

   // Make sure only 1 message was delivered.
   assertNotNull(consumer.receive(1000));
   assertNull(consumer.receiveNoWait());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:JMSUsecase1Test.java


示例15: testMessageCompression

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Test(timeout = 60 * 1000)
public void testMessageCompression() throws Exception {

   ActiveMQConnection localAmqConnection = (ActiveMQConnection) localConnection;
   localAmqConnection.setUseCompression(true);

   MessageConsumer consumer1 = remoteSession.createConsumer(included);
   MessageProducer producer = localSession.createProducer(included);
   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

   waitForConsumerRegistration(localBroker, 1, included);

   for (int i = 0; i < MESSAGE_COUNT; i++) {
      Message test = localSession.createTextMessage("test-" + i);
      producer.send(test);
      Message msg = consumer1.receive(3000);
      assertNotNull(msg);
      ActiveMQMessage amqMessage = (ActiveMQMessage) msg;
      assertTrue(amqMessage.isCompressed());
   }
   // ensure no more messages received
   assertNull(consumer1.receive(1000));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:SimpleNetworkTest.java


示例16: 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);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:AdvisoryTempDestinationTests.java


示例17: 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);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:AdvisoryTests.java


示例18: assertMessageValid

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
protected void assertMessageValid(int index, Message message) throws JMSException {
   // check if broker path has been set
   assertEquals("localhost", message.getStringProperty("BrokerPath"));
   ActiveMQMessage amqMsg = (ActiveMQMessage) message;
   if (index == 7) {
      // check custom expiration
      assertTrue("expiration is in range, depends on two distinct calls to System.currentTimeMillis", 1500 < amqMsg.getExpiration() - amqMsg.getTimestamp());
   } else if (index == 9) {
      // check ceiling
      assertTrue("expiration ceeling is in range, depends on two distinct calls to System.currentTimeMillis", 59500 < amqMsg.getExpiration() - amqMsg.getTimestamp());
   } else {
      // check default expiration
      assertEquals(1000, amqMsg.getExpiration() - amqMsg.getTimestamp());
   }
   super.assertMessageValid(index, message);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:PluginBrokerTest.java


示例19: onMessage

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Override
public void onMessage(Message message) {
  if (message instanceof ActiveMQMessage
      && ((ActiveMQMessage) message).getDataStructure() instanceof RemoveInfo) {
    RemoveInfo removeInfo = (RemoveInfo) ((ActiveMQMessage) message).getDataStructure();
    if (removeInfo.isConsumerRemove()) {
      suiteExecutor.abort();
    }
  }
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:11,代码来源:TestLifeCycle.java


示例20: onMessage_withNotRemovedConsumer_expectNotAbortedRun

import org.apache.activemq.command.ActiveMQMessage; //导入依赖的package包/类
@Test
public void onMessage_withNotRemovedConsumer_expectNotAbortedRun() throws Exception {
  ActiveMQMessage message = Mockito.mock(ActiveMQMessage.class);
  RemoveInfo removeInfo = Mockito.mock(RemoveInfo.class);
  when(message.getDataStructure()).thenReturn(removeInfo);
  when(removeInfo.isConsumerRemove()).thenReturn(false);
  tested.onMessage(message);
  verify(suiteExecutor, times(0)).abort();
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:10,代码来源:TestLifeCycleTest.java



注:本文中的org.apache.activemq.command.ActiveMQMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompactionExecutorStatsCollector类代码示例发布时间:2022-05-22
下一篇:
Java HttpHosts类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap