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


Java ActiveMQMessage.setStringProperty方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: slowConsumer

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
@Override
public void slowConsumer(ConnectionContext context, Destination destination,Subscription subs) {
    super.slowConsumer(context, destination,subs);
    try {
        if (!AdvisorySupport.isAdvisoryTopic(destination.getActiveMQDestination())) {
            ActiveMQTopic topic = AdvisorySupport.getSlowConsumerAdvisoryTopic(destination.getActiveMQDestination());
            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
            advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, subs.getConsumerInfo().getConsumerId().toString());
            fireAdvisory(context, topic, subs.getConsumerInfo(), null, advisoryMessage);
        }
    } catch (Exception e) {
        handleFireFailure("slow consumer", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:15,代码来源:AdvisoryBroker.java

示例6: fastProducer

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
@Override
public void fastProducer(ConnectionContext context,ProducerInfo producerInfo,ActiveMQDestination destination) {
    super.fastProducer(context, producerInfo, destination);
    try {
        if (!AdvisorySupport.isAdvisoryTopic(destination)) {
            ActiveMQTopic topic = AdvisorySupport.getFastProducerAdvisoryTopic(destination);
            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
            advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_PRODUCER_ID, producerInfo.getProducerId().toString());
            fireAdvisory(context, topic, producerInfo, null, advisoryMessage);
        }
    } catch (Exception e) {
        handleFireFailure("fast producer", e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:15,代码来源:AdvisoryBroker.java

示例7: 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

示例8: onMessageDispatch

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException {
    ActiveMQMessage message = (ActiveMQMessage)md.getMessage();
    if (ackMode == CLIENT_ACK) {
        synchronized (this) {
            dispatchedMessage.put(message.getMessageId(), md);
        }
    } else if (ackMode == INDIVIDUAL_ACK) {
        synchronized (this) {
            dispatchedMessage.put(message.getMessageId(), md);
        }
    } else if (ackMode == AUTO_ACK) {
        MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1);
        protocolConverter.getStompTransport().sendToActiveMQ(ack);
    }

    boolean ignoreTransformation = false;

    if (transformation != null && !( message instanceof ActiveMQBytesMessage ) ) {
        message.setReadOnlyProperties(false);
        message.setStringProperty(Stomp.Headers.TRANSFORMATION, transformation);
    } else {
        if (message.getStringProperty(Stomp.Headers.TRANSFORMATION) != null) {
            ignoreTransformation = true;
        }
    }

    StompFrame command = protocolConverter.convertMessage(message, ignoreTransformation);

    command.setAction(Stomp.Responses.MESSAGE);
    if (subscriptionId != null) {
        command.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, subscriptionId);
    }

    if (ackId != null) {
        command.getHeaders().put(Stomp.Headers.Message.ACK_ID, ackId);
    }

    protocolConverter.getStompTransport().sendToStomp(command);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:40,代码来源:StompSubscription.java

示例9: onSlowConsumer

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
@Override
public void onSlowConsumer(ServerConsumer consumer) {
   if (consumer.getProtocolData() != null && consumer.getProtocolData() instanceof AMQConsumer) {
      AMQConsumer amqConsumer = (AMQConsumer) consumer.getProtocolData();
      ActiveMQTopic topic = AdvisorySupport.getSlowConsumerAdvisoryTopic(amqConsumer.getOpenwireDestination());
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      try {
         advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, amqConsumer.getId().toString());
         protocolManager.fireAdvisory(context, topic, advisoryMessage, amqConsumer.getId(), null);
      } catch (Exception e) {
         ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:OpenWireConnection.java

示例10: copyStandardHeadersFromFrameToMessage

import org.apache.activemq.command.ActiveMQMessage; //导入方法依赖的package包/类
public static void copyStandardHeadersFromFrameToMessage(ProtocolConverter converter, StompFrame command, ActiveMQMessage msg, FrameTranslator ft) throws ProtocolException, JMSException {
    final Map<String, String> headers = new HashMap<String, String>(command.getHeaders());
    final String destination = headers.remove(Stomp.Headers.Send.DESTINATION);
    msg.setDestination(ft.convertDestination(converter, destination, true));

    // the standard JMS headers
    msg.setJMSCorrelationID(headers.remove(Stomp.Headers.Send.CORRELATION_ID));

    Object o = headers.remove(Stomp.Headers.Send.EXPIRATION_TIME);
    if (o != null) {
        msg.setJMSExpiration(Long.parseLong((String)o));
    }

    o = headers.remove(Stomp.Headers.Message.TIMESTAMP);
    if (o != null) {
        msg.setJMSTimestamp(Long.parseLong((String)o));
    } else {
        msg.setJMSTimestamp(System.currentTimeMillis());
    }

    o = headers.remove(Stomp.Headers.Send.PRIORITY);
    if (o != null) {
        msg.setJMSPriority(Integer.parseInt((String)o));
    } else {
        msg.setJMSPriority(javax.jms.Message.DEFAULT_PRIORITY);
    }

    o = headers.remove(Stomp.Headers.Send.TYPE);
    if (o != null) {
        msg.setJMSType((String)o);
    }

    o = headers.remove(Stomp.Headers.Send.REPLY_TO);
    if (o != null) {
        try {
            ActiveMQDestination dest = ft.convertDestination(converter, (String)o, false);
            msg.setJMSReplyTo(dest);
        } catch (ProtocolException pe) {
            msg.setStringProperty("reply-to", (String)o);
        }
    }

    o = headers.remove(Stomp.Headers.Send.PERSISTENT);
    if (o != null) {
        msg.setPersistent("true".equals(o));
    }

    // Stomp specific headers
    headers.remove(Stomp.Headers.RECEIPT_REQUESTED);

    // Since we take the rest of the header and put them in properties which could then
    // be sent back to a STOMP consumer we need to sanitize anything which could be in
    // Stomp.Headers.Message and might get passed through to the consumer
    headers.remove(Stomp.Headers.Message.MESSAGE_ID);
    headers.remove(Stomp.Headers.Message.REDELIVERED);
    headers.remove(Stomp.Headers.Message.SUBSCRIPTION);
    headers.remove(Stomp.Headers.Message.USERID);

    // now the general headers
    msg.setProperties(headers);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:62,代码来源:FrameTranslator.java

示例11: 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.setStringProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。