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


Java MessageHandlingException类代码示例

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


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


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