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

Java MessageHandlingException类代码示例

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

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



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

示例1: doWrite

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
protected void doWrite(Message<?> message) throws Exception {
	Object payload = message.getPayload();
	if (payload instanceof String) {
		String data = (String)payload;
		if (delimiter != null) {
			processor.onNext(Buffer.wrap(data+delimiter));
		} else {
			processor.onNext(Buffer.wrap(data));
		}
		if (meter != null) {
			if ((meterCount++ % rateInterval) == 0) {
				meter.mark(rateInterval);
				log.info("METER: 1 minute rate = " + meter.getOneMinuteRate() + " mean rate = " + meter.getMeanRate());
			}
		}
	} else {
		throw new MessageHandlingException(message, "message not a String");
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:21,代码来源:GpfdistMessageHandler.java


示例2: handleRequestMessage

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
protected Object handleRequestMessage(final Message<?> requestMessage) {
	
	if (!running) {
		return null;
	}
	
	Future<Object> response = executorService.submit(new Callable<Object>() {
		public Object call() throws Exception {
			byte[] requestData = requestConverter.convert(requestMessage.getPayload());
			socket.send(requestData);
			byte[] replyData = socket.recv();
			if (replyData == null) {
				socket.close();
				ZmqOutboundGateway.this.connect();
				throw ZmqEndpointUtil.buildMessageHandlingException(requestMessage, socket.base().errno());
			}
			return replyConverter.convert(replyData);
		}
	});
			
	try {
		return response.get();
	} catch (Throwable t) {
		throw new MessageHandlingException(requestMessage, t);
	}
}
 
开发者ID:moonkev,项目名称:spring-integration-zmq,代码行数:27,代码来源:ZmqOutboundGateway.java


示例3: verifyHeadersAreJustWrong

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void verifyHeadersAreJustWrong() throws IOException {
  // assemble
  Client mockClient = mockClientFactory.getClient();
  Queue queue = mock(Queue.class);
  when(mockClient.queue("queue3")).thenReturn(queue);

  // the message sender does it's best to convert any header value
  String timeout = "x";

  // act
  c3.send(MessageBuilder
    .withPayload("message3")
    .setHeader("ironmq_queue", "queue3")
    .setHeader(IronMqMessageHeaders.TIMEOUT, timeout)
    .build());

  // assert
  verify(mockClient).queue("queue3");
  verify(queue, times(0)).push(anyString(), anyLong());
}
 
开发者ID:trevershick,项目名称:ironmq-si,代码行数:22,代码来源:IronMQOutboundAdapterTest.java


示例4: testEvaluationIncorrectTupleInput

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void testEvaluationIncorrectTupleInput() {
	Tuple incompleteInputTuple = TupleBuilder.tuple()
			//	missing data type
			.put(TF_SHAPE, new long[0])
			.put(TF_VALUE, new byte[0])
			.build();
	testEvaluation(incompleteInputTuple);
}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:10,代码来源:LinearRegressionTensorflowProcessorIntegrationTests.java


示例5: resolveArgument

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, Message<?> message)
		throws Exception {
	Principal user = ((WampMessage) message).getPrincipal();
	if (user == null) {
		throw new MessageHandlingException(message,
				"No \"PRINCIPAL\" header in message");
	}
	return user;
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:11,代码来源:PrincipalMethodArgumentResolver.java


示例6: missingPrincipalTest

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void missingPrincipalTest() throws Exception {
	CallMessage callMessage = new CallMessage(1, "call");
	TestPrincipal testPrincipal = new TestPrincipal("testPrincipal");
	assertThat(this.resolver.resolveArgument(this.principalParameter, callMessage))
			.isEqualTo(testPrincipal);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:8,代码来源:PrincipalMethodArgumentResolverTest.java


示例7: testEvaluationIncorrectTupleInput

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void testEvaluationIncorrectTupleInput() throws InterruptedException {
	Tuple incompleteInputTuple = TupleBuilder.tuple()
			//	missing data type
			.put(TF_SHAPE, new long[0])
			.put(TF_VALUE, new byte[0])
			.build();
	testEvaluation(incompleteInputTuple);
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:tensorflow,代码行数:10,代码来源:LinearRegressionTensorflowProcessorIntegrationTests.java


示例8: handleMessageInternal

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
protected final void handleMessageInternal(Message<?> message) throws Exception {
	try {
		doWrite(message);
	}
	catch (Exception e) {
		throw new MessageHandlingException(message,
				"failed to write Message payload to GPDB/HAWQ", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:11,代码来源:AbstractGpfdistMessageHandler.java


示例9: doHandleMessage

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
private void doHandleMessage(MessageHandler handler, Message<?> message) {
	try {
		handler.handleMessage(message);
	}
	catch (Throwable t) { // NOSONAR
		throw new MessageHandlingException(message, t);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:9,代码来源:DefaultPollableMessageSource.java


示例10: testStreamListenerJavaSerializationNonSerializable

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test(expected = MessageHandlingException.class)
public void testStreamListenerJavaSerializationNonSerializable() throws Exception {
	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0c",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0c",
			getDestinationNameDelimiter()), "test-3", moduleInputChannel, consumerBindingProperties.getConsumer());
	try {
		Station station = new Station();
		Message<?> message = MessageBuilder.withPayload(station)
				.setHeader(MessageHeaders.CONTENT_TYPE,
						MessageConverterUtils.X_JAVA_SERIALIZED_OBJECT)
				.build();
		moduleOutputChannel.send(message);
	}
	finally {
		producerBinding.unbind();
		consumerBinding.unbind();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:32,代码来源:AbstractBinderTests.java


示例11: resolveArgument

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, Message<?> message)
		throws Exception {
	Principal user = ((WampMessage) message).getPrincipal();

	if (user == null) {
		throw new MessageHandlingException(message,
				"No \"principal\" header in message");
	}

	return user;
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:13,代码来源:PrincipalMethodArgumentResolver.java


示例12: resolveArgument

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, Message<?> message)
		throws Exception {
	WampSession wampSession = ((WampMessage) message).getWampSession();

	if (wampSession == null) {
		throw new MessageHandlingException(message,
				"No \"wampSession\" header in message");
	}

	return wampSession;
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:13,代码来源:WampSessionMethodArgumentResolver.java


示例13: missingPrincipalTest

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void missingPrincipalTest() throws Exception {
	CallMessage callMessage = new CallMessage("1", "call");
	TestPrincipal testPrincipal = new TestPrincipal("testPrincipal");
	assertThat(this.resolver.resolveArgument(this.principalParameter, callMessage))
			.isEqualTo(testPrincipal);
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:8,代码来源:PrincipalMethodArgumentResolverTest.java


示例14: missingWampSessionTest

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void missingWampSessionTest() throws Exception {
	CallMessage callMessage = new CallMessage("1", "call");
	WampSession wampSession = new WampSession(this.nativeSession);
	assertThat(this.resolver.resolveArgument(this.wampSessionParameter, callMessage))
			.isEqualTo(wampSession);
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:8,代码来源:WampSessionMethodArgumentResolverTest.java


示例15: handleRequestMessage

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
protected Object handleRequestMessage(final Message<?> requestMessage) {
	if (!running) {
		return null;
	}
	
	Future<Object> response = executorService.submit(new Callable<Object>() {
		public Object call() throws Exception {
			byte[] requestData = requestConverter.convert(requestMessage.getPayload());
			int retriesLeft = retryCount;
			while (!Thread.currentThread().isInterrupted()) {
				socket.send(requestData);
				PollItem items[] = { new PollItem(socket, Poller.POLLIN) };
				int rc = ZMQ.poll(items, socketReceiveTimeout);
				if (rc == -1) {
					break;
				}
				if (items[0].isReadable()) {
					byte[] reply = socket.recv();
					return replyConverter.convert(reply);
				} else if (--retriesLeft == 0) {
					break;
				} else {
					ZmqLazyPirateGateway.this.connect();
				}
			}
			ZmqLazyPirateGateway.this.connect();
			return null;
		}
	});
			
	try {
		return response.get();
	} catch (Throwable t) {
		throw new MessageHandlingException(requestMessage, t);
	}
}
 
开发者ID:moonkev,项目名称:spring-integration-zmq,代码行数:37,代码来源:ZmqLazyPirateGateway.java


示例16: buildMessageHandlingException

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
public static MessageHandlingException buildMessageHandlingException(Message<?> failedMessage, int errno)  {
	if (errno == ZError.ETERM) {
		return new MessageHandlingException(failedMessage, "ZMQ Context has been terminated");
	} else if (errno == ZError.EAGAIN) {
		return new MessageHandlingException(failedMessage, "ZMQ socket timeout out while attempting to send or receive data over zmq socket");
	} else {
		return new MessageHandlingException(failedMessage, "Unknown error while attempting to send or receive data over zmq socket");
	}
}
 
开发者ID:moonkev,项目名称:spring-integration-zmq,代码行数:10,代码来源:ZmqEndpointUtil.java


示例17: handleMissingValue

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
protected void handleMissingValue(String name, MethodParameter parameter, Message<?> message) {
	throw new MessageHandlingException(message, "Missing path template variable '" + name +
			"' for method parameter type [" + parameter.getParameterType() + "]");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:DestinationVariableMethodArgumentResolver.java


示例18: handleMissingValue

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Override
protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) {
	throw new MessageHandlingException(message, "Missing header '" + headerName +
			"' for method parameter type [" + parameter.getParameterType() + "]");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:HeaderMethodArgumentResolver.java


示例19: resolveArgumentNotFound

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void resolveArgumentNotFound() throws Exception {
	Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
	this.resolver.resolveArgument(this.paramRequired, message);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:HeaderMethodArgumentResolverTests.java


示例20: resolveArgumentNotFound

import org.springframework.messaging.MessageHandlingException; //导入依赖的package包/类
@Test(expected = MessageHandlingException.class)
public void resolveArgumentNotFound() throws Exception {
	Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
	this.resolver.resolveArgument(this.paramAnnotated, message);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:DestinationVariableMethodArgumentResolverTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CommitBlockSynchronizationRequestProto类代码示例发布时间:2022-05-22
下一篇:
Java DatagramSocket类代码示例发布时间: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