当前位置: 首页>>代码示例>>Java>>正文


Java ActiveMQMessage.setMessageId方法代码示例

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


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

示例1: fireAdvisory

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void fireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId, ActiveMQMessage advisoryMessage) throws Exception {
    if (getBrokerService().isStarted()) {
        //set properties
        advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_NAME, getBrokerName());
        String id = getBrokerId() != null ? getBrokerId().getValue() : "NOT_SET";
        advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID, id);

        String url = getBrokerService().getVmConnectorURI().toString();
        if (getBrokerService().getDefaultSocketURIString() != null) {
            url = getBrokerService().getDefaultSocketURIString();
        }
        advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL, url);

        //set the data structure
        advisoryMessage.setDataStructure(command);
        advisoryMessage.setPersistent(false);
        advisoryMessage.setType(AdvisorySupport.ADIVSORY_MESSAGE_TYPE);
        advisoryMessage.setMessageId(new MessageId(advisoryProducerId, messageIdGenerator.getNextSequenceId()));
        advisoryMessage.setTargetConsumerId(targetConsumerId);
        advisoryMessage.setDestination(topic);
        advisoryMessage.setResponseRequired(false);
        advisoryMessage.setProducerId(advisoryProducerId);
        boolean originalFlowControl = context.isProducerFlowControl();
        final ProducerBrokerExchange producerExchange = new ProducerBrokerExchange();
        producerExchange.setConnectionContext(context);
        producerExchange.setMutable(true);
        producerExchange.setProducerState(new ProducerState(new ProducerInfo()));
        try {
            context.setProducerFlowControl(false);
            next.send(producerExchange, advisoryMessage);
        } finally {
            context.setProducerFlowControl(originalFlowControl);
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:36,代码来源:AdvisoryBroker.java

示例2: send

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
/**
 * Internal send method optimized: - It does not copy the message - It can
 * only handle ActiveMQ messages. - You can specify if the send is async or
 * sync - Does not allow you to send /w a transaction.
 */
void send(ActiveMQDestination destination, ActiveMQMessage msg, MessageId messageId, int deliveryMode, int priority, long timeToLive, boolean async) throws JMSException {
    checkClosedOrFailed();

    if (destination.isTemporary() && isDeleted(destination)) {
        throw new JMSException("Cannot publish to a deleted Destination: " + destination);
    }

    msg.setJMSDestination(destination);
    msg.setJMSDeliveryMode(deliveryMode);
    long expiration = 0L;

    if (!isDisableTimeStampsByDefault()) {
        long timeStamp = System.currentTimeMillis();
        msg.setJMSTimestamp(timeStamp);
        if (timeToLive > 0) {
            expiration = timeToLive + timeStamp;
        }
    }

    msg.setJMSExpiration(expiration);
    msg.setJMSPriority(priority);
    msg.setJMSRedelivered(false);
    msg.setMessageId(messageId);
    msg.onSend();
    msg.setProducerId(msg.getMessageId().getProducerId());

    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending message: " + msg);
    }

    if (async) {
        asyncSendPacket(msg);
    } else {
        syncSendPacket(msg);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:42,代码来源:ActiveMQConnection.java

示例3: configure

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
protected void configure(ActiveMQMessage msg) throws JMSException {
    long sequenceNumber = messageSequence.incrementAndGet();
    msg.setMessageId(new MessageId(producerId, sequenceNumber));
    msg.onSend();
    msg.setProducerId(producerId);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:7,代码来源:QueryBasedSubscriptionRecoveryPolicy.java

示例4: testSerialization

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
   ActiveMQMessageAuditNoSync audit = new ActiveMQMessageAuditNoSync();

   byte[] bytes = serialize(audit);
   LOG.debug("Length: " + bytes.length);
   audit = recover(bytes);

   List<MessageReference> list = new ArrayList<>();

   for (int j = 0; j < 1000; j++) {
      ProducerId pid = new ProducerId();
      pid.setConnectionId("test");
      pid.setSessionId(0);
      pid.setValue(j);
      LOG.debug("producer " + j);

      for (int i = 0; i < 1000; i++) {
         MessageId id = new MessageId();
         id.setProducerId(pid);
         id.setProducerSequenceId(i);
         ActiveMQMessage msg = new ActiveMQMessage();
         msg.setMessageId(id);
         list.add(msg);
         assertFalse(audit.isDuplicate(msg.getMessageId().toString()));

         if (i % 100 == 0) {
            bytes = serialize(audit);
            LOG.debug("Length: " + bytes.length);
            audit = recover(bytes);
         }

         if (i % 250 == 0) {
            for (MessageReference message : list) {
               audit.rollback(message.getMessageId().toString());
            }
            list.clear();
            bytes = serialize(audit);
            LOG.debug("Length: " + bytes.length);
            audit = recover(bytes);
         }
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:44,代码来源:ActiveMQMessageAuditTest.java

示例5: fireAdvisory

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public void fireAdvisory(AMQConnectionContext context,
                         ActiveMQTopic topic,
                         Command command,
                         ConsumerId targetConsumerId,
                         String originalConnectionId) throws Exception {
   if (!this.isSupportAdvisory()) {
      return;
   }
   ActiveMQMessage advisoryMessage = new ActiveMQMessage();

   if (originalConnectionId == null) {
      originalConnectionId = context.getConnectionId().getValue();
   }
   advisoryMessage.setStringProperty(MessageUtil.CONNECTION_ID_PROPERTY_NAME.toString(), originalConnectionId);
   advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_NAME, getBrokerName());
   String id = getBrokerId() != null ? getBrokerId().getValue() : "NOT_SET";
   advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID, id);

   String url = context.getConnection().getLocalAddress();

   advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL, url);

   // set the data structure
   advisoryMessage.setDataStructure(command);
   advisoryMessage.setPersistent(false);
   advisoryMessage.setType(AdvisorySupport.ADIVSORY_MESSAGE_TYPE);
   advisoryMessage.setMessageId(new MessageId(advisoryProducerId, messageIdGenerator.getNextSequenceId()));
   advisoryMessage.setTargetConsumerId(targetConsumerId);
   advisoryMessage.setDestination(topic);
   advisoryMessage.setResponseRequired(false);
   advisoryMessage.setProducerId(advisoryProducerId);
   boolean originalFlowControl = context.isProducerFlowControl();
   final AMQProducerBrokerExchange producerExchange = new AMQProducerBrokerExchange();
   producerExchange.setConnectionContext(context);
   producerExchange.setProducerState(new ProducerState(new ProducerInfo()));
   try {
      context.setProducerFlowControl(false);
      AMQSession sess = context.getConnection().getAdvisorySession();
      if (sess != null) {
         sess.send(producerExchange.getProducerState().getInfo(), advisoryMessage, false);
      }
   } finally {
      context.setProducerFlowControl(originalFlowControl);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:46,代码来源:OpenWireProtocolManager.java


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