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


Java MessagingException类代码示例

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


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

示例1: handler

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Bean
@ServiceActivator(inputChannel = "mqttInputChannel")
public MessageHandler handler() {
    return new MessageHandler() {
        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            if (raptorMessageHandlerWrapper != null) {
                try {
                    DispatcherPayload payload = DispatcherPayload.parseJSON(message.getPayload().toString());
                    raptorMessageHandlerWrapper.handle(payload, message.getHeaders());
                } catch (Exception e) {
                    throw new MessagingException("Exception handling message", e);
                }
            }
        }
    };
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:18,代码来源:MqttConfiguration.java

示例2: syncSend

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Same to {@link #syncSend(String, Message)} with send timeout specified in addition.
 *
 * @param destination formats: `topicName:tags`
 * @param message     {@link org.springframework.messaging.Message}
 * @param timeout     send timeout with millis
 * @return {@link SendResult}
 */
public SendResult syncSend(String destination, Message<?> message, long timeout) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("syncSend failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        long now = System.currentTimeMillis();
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        SendResult sendResult = producer.send(rocketMsg, timeout);
        long costTime = System.currentTimeMillis() - now;
        log.debug("send message cost: {} ms, msgId:{}", costTime, sendResult.getMsgId());
        return sendResult;
    } catch (Exception e) {
        log.info("syncSend failed. destination:{}, message:{} ", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:27,代码来源:RocketMQTemplate.java

示例3: syncSendOrderly

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Same to {@link #syncSendOrderly(String, Message, String)} with send timeout specified in addition.
 *
 * @param destination formats: `topicName:tags`
 * @param message     {@link org.springframework.messaging.Message}
 * @param hashKey     use this key to select queue. for example: orderId, productId ...
 * @param timeout     send timeout with millis
 * @return {@link SendResult}
 */
public SendResult syncSendOrderly(String destination, Message<?> message, String hashKey, long timeout) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("syncSendOrderly failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        long now = System.currentTimeMillis();
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        SendResult sendResult = producer.send(rocketMsg, messageQueueSelector, hashKey, timeout);
        long costTime = System.currentTimeMillis() - now;
        log.debug("send message cost: {} ms, msgId:{}", costTime, sendResult.getMsgId());
        return sendResult;
    } catch (Exception e) {
        log.info("syncSendOrderly failed. destination:{}, message:{} ", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:28,代码来源:RocketMQTemplate.java

示例4: asyncSendOrderly

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Same to {@link #asyncSendOrderly(String, Message, String, SendCallback)} with send timeout specified in
 * addition.
 *
 * @param destination  formats: `topicName:tags`
 * @param message      {@link org.springframework.messaging.Message}
 * @param hashKey      use this key to select queue. for example: orderId, productId ...
 * @param sendCallback {@link SendCallback}
 * @param timeout      send timeout with millis
 */
public void asyncSendOrderly(String destination, Message<?> message, String hashKey, SendCallback sendCallback,
                             long timeout) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("asyncSendOrderly failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        producer.send(rocketMsg, messageQueueSelector, hashKey, sendCallback, timeout);
    } catch (Exception e) {
        log.info("asyncSendOrderly failed. destination:{}, message:{} ", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:26,代码来源:RocketMQTemplate.java

示例5: preHandle

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
public Message<?> preHandle(Message<?> message) throws MessagingException {
	String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
	if (!getBroadcastDestination().equals(destination)) {
		return message;
	}
	SimpMessageHeaderAccessor accessor = getAccessor(message, SimpMessageHeaderAccessor.class);
	if (accessor.getSessionId() == null) {
		// Our own broadcast
		return null;
	}
	destination = accessor.getFirstNativeHeader(ORIGINAL_DESTINATION);
	if (logger.isTraceEnabled()) {
		logger.trace("Checking unresolved user destination: " + destination);
	}
	SimpMessageHeaderAccessor newAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
	for (String name : accessor.toNativeHeaderMap().keySet()) {
		if (NO_COPY_LIST.contains(name)) {
			continue;
		}
		newAccessor.setNativeHeader(name, accessor.getFirstNativeHeader(name));
	}
	newAccessor.setDestination(destination);
	newAccessor.setHeader(SimpMessageHeaderAccessor.IGNORE_ERROR, true); // ensure send doesn't block
	return MessageBuilder.createMessage(message.getPayload(), newAccessor.getMessageHeaders());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:UserDestinationMessageHandler.java

示例6: handleMessage

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Override
public void handleMessage(Message<?> message) throws MessagingException {
	String destination = getDestination(message);
	if (destination == null) {
		return;
	}
	String lookupDestination = getLookupDestination(destination);
	if (lookupDestination == null) {
		return;
	}
	MessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getMutableAccessor(message);
	headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination);
	headerAccessor.setLeaveMutable(true);
	message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders());

	if (logger.isDebugEnabled()) {
		logger.debug("Searching methods to handle " + headerAccessor.getShortLogMessage(message.getPayload()));
	}

	handleMessageInternal(message, lookupDestination);
	headerAccessor.setImmutable();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:AbstractMethodMessageHandler.java

示例7: datasetSinkMessageHandler

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Bean
@ServiceActivator(inputChannel = "toSink")
public MessageHandler datasetSinkMessageHandler(final DatasetOperations datasetOperations) {
	return new MessageHandler() {

		@Override
		public void handleMessage(Message<?> message) throws MessagingException {
			Object payload = message.getPayload();
			if (payload instanceof Collection<?>) {
				Collection<?> payloads = (Collection<?>) payload;
				logger.debug("Writing a collection of {} POJOs" + payloads.size());
				datasetOperations.write((Collection<?>) message.getPayload());
			}
			else {
				// This should never happen since message handler is fronted by an aggregator
				throw new IllegalStateException("Expected a collection of POJOs but received " +
						message.getPayload().getClass().getName());
			}
		}
	};
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:hdfs,代码行数:22,代码来源:HdfsDatasetSinkConfiguration.java

示例8: processRecords

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@SneakyThrows
@Override
public void processRecords(ProcessRecordsInput processRecordsInput) {
    List<Record> records = processRecordsInput.getRecords();
    // Used to update the last processed record
    IRecordProcessorCheckpointer checkpointer = processRecordsInput.getCheckpointer();
    log.info("Recovering records from kinesis.");
    for (Record r : records) {
        try {
            int len = r.getData().remaining();
            byte[] buffer = new byte[len];
            r.getData().get(buffer);
            String json = new String(buffer, "UTF-8");
            ZombieLecture lecture = mapper.readValue(json, ZombieLecture.class);
            this.processZombieLecture(lecture);
            log.debug(processedRecords++ + ": " + json);
            if (processedRecords % 1000 == 999) {
                // Uncomment next line to keep track of the processed lectures. 
                checkpointer.checkpoint();
            }
        } catch (UnsupportedEncodingException | MessagingException ex) {
            log.warn(ex.getMessage());
        }
    }
}
 
开发者ID:capside,项目名称:aws-kinesis-zombies,代码行数:26,代码来源:ZombieRecordProcessor.java

示例9: asyncSend

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Same to {@link #asyncSend(String, Message, SendCallback)} with send timeout specified in addition.
 *
 * @param destination  formats: `topicName:tags`
 * @param message      {@link org.springframework.messaging.Message}
 * @param sendCallback {@link SendCallback}
 * @param timeout      send timeout with millis
 */
public void asyncSend(String destination, Message<?> message, SendCallback sendCallback, long timeout) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("asyncSend failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        producer.send(rocketMsg, sendCallback, timeout);
    } catch (Exception e) {
        log.info("asyncSend failed. destination:{}, message:{} ", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:23,代码来源:RocketMQTemplate.java

示例10: sendOneWay

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Similar to <a href="https://en.wikipedia.org/wiki/User_Datagram_Protocol">UDP</a>, this method won't wait for
 * acknowledgement from broker before return. Obviously, it has maximums throughput yet potentials of message loss.
 * <p>
 * One-way transmission is used for cases requiring moderate reliability, such as log collection.
 *
 * @param destination formats: `topicName:tags`
 * @param message     {@link org.springframework.messaging.Message}
 */
public void sendOneWay(String destination, Message<?> message) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("sendOneWay failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        producer.sendOneway(rocketMsg);
    } catch (Exception e) {
        log.info("sendOneWay failed. destination:{}, message:{} ", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:24,代码来源:RocketMQTemplate.java

示例11: sendOneWayOrderly

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
/**
 * Same to {@link #sendOneWay(String, Message)} with send orderly with hashKey by specified.
 *
 * @param destination formats: `topicName:tags`
 * @param message     {@link org.springframework.messaging.Message}
 * @param hashKey     use this key to select queue. for example: orderId, productId ...
 */
public void sendOneWayOrderly(String destination, Message<?> message, String hashKey) {
    if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
        log.info("sendOneWayOrderly failed. destination:{}, message is null ", destination);
        throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
    }

    try {
        org.apache.rocketmq.common.message.Message rocketMsg = convertToRocketMsg(destination, message);
        producer.sendOneway(rocketMsg, messageQueueSelector, hashKey);
    } catch (Exception e) {
        log.info("sendOneWayOrderly failed. destination:{}, message:{}", destination, message);
        throw new MessagingException(e.getMessage(), e);
    }
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:22,代码来源:RocketMQTemplate.java

示例12: convertAndSendToUser

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Override
public void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers,
		MessagePostProcessor postProcessor) throws MessagingException {

	Assert.notNull(user, "User must not be null");
	user = StringUtils.replace(user, "/", "%2F");
	super.convertAndSend(this.destinationPrefix + user + destination, payload, headers, postProcessor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:SimpMessagingTemplate.java

示例13: handleMessage

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Override
public void handleMessage(Message<?> message) throws MessagingException {
	if (this.broadcastHandler != null) {
		message = this.broadcastHandler.preHandle(message);
		if (message == null) {
			return;
		}
	}
	UserDestinationResult result = this.destinationResolver.resolveDestination(message);
	if (result == null) {
		return;
	}
	if (result.getTargetDestinations().isEmpty()) {
		if (logger.isTraceEnabled()) {
			logger.trace("No active sessions for user destination: " + result.getSourceDestination());
		}
		if (this.broadcastHandler != null) {
			this.broadcastHandler.handleUnresolved(message);
		}
		return;
	}
	SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message);
	initHeaders(accessor);
	accessor.setNativeHeader(ORIGINAL_DESTINATION, result.getSubscribeDestination());
	accessor.setLeaveMutable(true);
	message = MessageBuilder.createMessage(message.getPayload(), accessor.getMessageHeaders());
	if (logger.isTraceEnabled()) {
		logger.trace("Translated " + result.getSourceDestination() + " -> " + result.getTargetDestinations());
	}
	for (String target : result.getTargetDestinations()) {
		this.messagingTemplate.send(target, message);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:UserDestinationMessageHandler.java

示例14: handleMessage

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Override
public void handleMessage(Message<?> message) throws MessagingException {
	if (SimpMessageType.HEARTBEAT == SimpMessageHeaderAccessor.getMessageType(message.getHeaders())) {
		return;
	}
	this.queue.add(message);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:StompBrokerRelayMessageHandlerIntegrationTests.java

示例15: sendAndReceive

import org.springframework.messaging.MessagingException; //导入依赖的package包/类
@Test
public void sendAndReceive() {

	SubscribableChannel channel = new ExecutorSubscribableChannel(this.executor);
	channel.subscribe(new MessageHandler() {
		@Override
		public void handleMessage(Message<?> message) throws MessagingException {
			MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
			replyChannel.send(new GenericMessage<String>("response"));
		}
	});

	String actual = this.template.convertSendAndReceive(channel, "request", String.class);
	assertEquals("response", actual);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:GenericMessagingTemplateTests.java


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