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


Java Message类代码示例

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


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

示例1: convertQueues

import org.apache.activemq.command.Message; //导入依赖的package包/类
/**
 * Determine the destinations associated with this message
 * Will be one destination for a Queue message or 1 or more for a Topic
 *
 * @param message
 * @return
 * @throws Exception
 */
private QueuesType convertQueues(final Message message) throws Exception {
    if (store == null || message.getDestination().isQueue()) {
        return QueuesType.builder()
                .withQueue(QueueType.builder()
                        .withName(message.getDestination().getPhysicalName()).build())
            .build();
    } else {
        final QueuesType.Builder<Void> queuesBuilder = QueuesType.builder();

        KahaDBUtil.getUnackedSubscriptions(store, message).forEach(sub -> {
            queuesBuilder.addQueue(QueueType.builder().withName(
                    ActiveMQDestination.createQueueNameForDurableSubscription(
                    true, sub.getClientId(), sub.getSubcriptionName())).build());
        });

        return queuesBuilder.build();
    }
}
 
开发者ID:apache,项目名称:activemq-cli-tools,代码行数:27,代码来源:OpenWireCoreMessageTypeConverter.java

示例2: publish

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
public void publish(final Message message, final KafkaTemplate<String, byte[]> kafkaTemplate) {

	try {
		final byte[] effectivePayload = message.getContent().getData();
		final String sourceTopic = message.getDestination().getPhysicalName();
		final String destTopic = this.getDestTopic(sourceTopic);
		kafkaTemplate.send(destTopic, effectivePayload);
	} catch (final Throwable t) {
		LOG.error("Exception occured", t);
	}
}
 
开发者ID:dcsolutions,项目名称:kalinka,代码行数:13,代码来源:MqttSparkClusterJmsMessagePublisher.java

示例3: updateMessage

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
public void updateMessage(Message message) throws IOException {
   if (throwExceptionOnUpdate) {
      if (numBeforeException > 0) {
         numBeforeException--;
         super.updateMessage(message);
      } else {
         // lets only do it once so we can validate transient store failure
         throwExceptionOnUpdate = false;

         //A message that has never been delivered will hit this exception
         throw new IOException("Hit our simulated exception writing the update to disk");
      }
   } else {
      super.updateMessage(message);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:RedeliveryRestartWithExceptionTest.java

示例4: receiveMessage

import org.apache.activemq.command.Message; //导入依赖的package包/类
public Message receiveMessage(StubConnection connection, long timeout) throws InterruptedException {
   while (true) {
      Object o = connection.getDispatchQueue().poll(timeout, TimeUnit.MILLISECONDS);

      if (o == null) {
         return null;
      }
      if (o instanceof MessageDispatch) {

         MessageDispatch dispatch = (MessageDispatch) o;
         if (dispatch.getMessage() == null) {
            return null;
         }
         dispatch.setMessage(dispatch.getMessage().copy());
         dispatch.getMessage().setRedeliveryCounter(dispatch.getRedeliveryCounter());
         return dispatch.getMessage();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:BrokerNetworkWithStuckMessagesTest.java

示例5: createBroker

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService answer = new BrokerService();
   answer.setPersistent(false);
   answer.setMessageAuthorizationPolicy(new MessageAuthorizationPolicy() {
      @Override
      public boolean isAllowedToConsume(ConnectionContext context, Message message) {
         try {
            Object value = message.getProperty("myHeader");
            return "abc".equals(value);
         } catch (IOException e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
            return false;
         }
      }
   });
   answer.addConnector(bindAddress);
   return answer;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:MessageAuthenticationTest.java

示例6: retryMessage

import org.apache.activemq.command.Message; //导入依赖的package包/类
/**
 * Moves a message back to its original destination
 */
public boolean retryMessage(String messageId) throws Exception {
    Queue queue = (Queue) destination;
    QueueMessageReference ref = queue.getMessage(messageId);
    Message rc = ref.getMessage();
    if (rc != null) {
        ActiveMQDestination originalDestination = rc.getOriginalDestination();
        if (originalDestination != null) {
            ConnectionContext context = BrokerSupport.getConnectionContext(broker.getContextBroker());
            return queue.moveMessageTo(context, ref, originalDestination);
        }
        else {
            throw new JMSException("No original destination for message: "+ messageId);
        }
    }
    else {
        throw new JMSException("Could not find message: "+ messageId);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:22,代码来源:QueueView.java

示例7: send

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
public void send(ProducerBrokerExchange exchange, Message message) throws Exception {
    if (exchange != null && exchange.getProducerState() != null && exchange.getProducerState().getInfo() != null) {
        ProducerInfo info = exchange.getProducerState().getInfo();
        if (info.getDestination() == null && info.getProducerId() != null) {
            ObjectName objectName = BrokerMBeanSupport.createProducerName(brokerObjectName, exchange.getConnectionContext().getClientId(), info);
            ProducerView view = this.dynamicDestinationProducers.get(objectName);
            if (view != null) {
                ActiveMQDestination dest = message.getDestination();
                if (dest != null) {
                    view.setLastUsedDestinationName(dest);
                }
            }
        }
     }
    super.send(exchange, message);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:18,代码来源:ManagedRegionBroker.java

示例8: send

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
public void send(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception {
    ActiveMQDestination activeMQDestination = messageSend.getDestination();
    if (!interceptorMap.isEmpty() && activeMQDestination != null) {
        Set<MessageInterceptor> set = interceptorMap.get(activeMQDestination);
        if (set != null && !set.isEmpty()) {
            for (MessageInterceptor mi : set) {
                mi.intercept(producerExchange, messageSend);
            }
        } else {
            super.send(producerExchange, messageSend);
        }

    } else {
        super.send(producerExchange, messageSend);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:18,代码来源:MessageInterceptorFilter.java

示例9: send

import org.apache.activemq.command.Message; //导入依赖的package包/类
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception {
    final ConnectionContext context = producerExchange.getConnectionContext();
    String userID = context.getUserName();
    if (isUseAuthenticatePrincipal()) {
        SecurityContext securityContext = context.getSecurityContext();
        if (securityContext != null) {
            Set<?> principals = securityContext.getPrincipals();
            if (principals != null) {
                for (Object candidate : principals) {
                    if (candidate instanceof UserPrincipal) {
                        userID = ((UserPrincipal)candidate).getName();
                        break;
                    }
                }
            }
        }
    }
    messageSend.setUserID(userID);
    super.send(producerExchange, messageSend);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:21,代码来源:UserIDBroker.java

示例10: doResend

import org.apache.activemq.command.Message; //导入依赖的package包/类
public static void doResend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination, boolean copy) throws Exception {       
    Message message = copy ? originalMessage.copy() : originalMessage;
    message.setOriginalDestination(message.getDestination());
    message.setOriginalTransactionId(message.getTransactionId());
    message.setDestination(deadLetterDestination);
    message.setTransactionId(null);
    message.setMemoryUsage(null);
    message.setRedeliveryCounter(0);
    boolean originalFlowControl = context.isProducerFlowControl();
    try {
        context.setProducerFlowControl(false);
        ProducerInfo info = new ProducerInfo();
        ProducerState state = new ProducerState(info);
        ProducerBrokerExchange producerExchange = new ProducerBrokerExchange();
        producerExchange.setProducerState(state);
        producerExchange.setMutable(true);
        producerExchange.setConnectionContext(context);
        context.getBroker().send(producerExchange, message);
    } finally {
        context.setProducerFlowControl(originalFlowControl);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:23,代码来源:BrokerSupport.java

示例11: addMessage

import org.apache.activemq.command.Message; //导入依赖的package包/类
/**
 * @param message
 * @throws IOException
 */
void addMessage(ConnectionContext context, final MessageStore destination, final Message message)
        throws IOException {

    if (message.getTransactionId() != null) {
        if (message.getTransactionId().isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) {
            destination.addMessage(context, message);
        } else {
            Tx tx = getTx(message.getTransactionId());
            tx.add(new AddMessageCommand(context) {
                @Override
                public Message getMessage() {
                    return message;
                }
                @Override
                public Future<Object> run(ConnectionContext ctx) throws IOException {
                    destination.addMessage(ctx, message);
                    return AbstractMessageStore.FUTURE;
                }

            });
        }
    } else {
        destination.addMessage(context, message);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:30,代码来源:KahaDBTransactionStore.java

示例12: onDispatch

import org.apache.activemq.command.Message; //导入依赖的package包/类
protected void onDispatch(final MessageReference node, final Message message) {
    Destination nodeDest = (Destination) node.getRegionDestination();
    if (nodeDest != null) {
        if (node != QueueMessageReference.NULL_MESSAGE) {
            nodeDest.getDestinationStatistics().getDispatched().increment();
            nodeDest.getDestinationStatistics().getInflight().increment();
            LOG.trace("{} dispatched: {} - {}, dispatched: {}, inflight: {}", new Object[]{ info.getConsumerId(), message.getMessageId(), message.getDestination(), dispatchCounter, dispatched.size() });
        }
    }

    if (info.isDispatchAsync()) {
        try {
            dispatchPending();
        } catch (IOException e) {
            context.getConnection().serviceExceptionAsync(e);
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:PrefetchSubscription.java

示例13: createMessageDispatch

import org.apache.activemq.command.Message; //导入依赖的package包/类
/**
 * @param node
 * @param message
 * @return MessageDispatch
 */
protected MessageDispatch createMessageDispatch(MessageReference node, Message message) {
    MessageDispatch md = new MessageDispatch();
    md.setConsumerId(info.getConsumerId());

    if (node == QueueMessageReference.NULL_MESSAGE) {
        md.setMessage(null);
        md.setDestination(null);
    } else {
        Destination regionDestination = (Destination) node.getRegionDestination();
        md.setDestination(regionDestination.getActiveMQDestination());
        md.setMessage(message);
        md.setRedeliveryCounter(node.getRedeliveryCounter());
    }

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

示例14: send

import org.apache.activemq.command.Message; //导入依赖的package包/类
/**
 * 
 */
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
    ActiveMQDestination destination = message.getDestination();
    if (destination.isComposite()) {
        ActiveMQDestination[] destinations = destination.getCompositeDestinations();
        for (int i = 0; i < destinations.length; i++) {
            if (i != 0) {
                message = message.copy();
                message.setMemoryUsage(null);
            }
            message.setOriginalDestination(destination);
            message.setDestination(destinations[i]);
            next.send(producerExchange, message);
        }
    } else {
        next.send(producerExchange, message);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:21,代码来源:CompositeDestinationBroker.java

示例15: addMessageLast

import org.apache.activemq.command.Message; //导入依赖的package包/类
@Override
public synchronized void addMessageLast(MessageReference node) throws Exception {
    if (node != null) {
        Message msg = node.getMessage();
        if (isStarted()) {
            if (!msg.isPersistent()) {
                nonPersistent.addMessageLast(node);
            }
        }
        if (msg.isPersistent()) {
            Destination dest = (Destination) msg.getRegionDestination();
            TopicStorePrefetch tsp = topics.get(dest);
            if (tsp != null) {
                tsp.addMessageLast(node);
                if (prioritizedMessages && immediatePriorityDispatch && tsp.isPaging()) {
                    if (msg.getPriority() > tsp.getLastRecoveredPriority()) {
                        tsp.recoverMessage(node.getMessage(), true);
                        LOG.trace("cached high priority ({} message: {}, current paged batch priority: {}, cache size: {}", new Object[]{ msg.getPriority(), msg.getMessageId(), tsp.getLastRecoveredPriority(), tsp.batchList.size()});
                    }
                }
            }
        }

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


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